netgen-4.9.13/0000777000175000001440000000000011377017541010077 500000000000000netgen-4.9.13/INSTALL0000644000175000001440000001547211240003504011034 00000000000000Basic Installation ================== These are generic installation instructions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, a file `config.cache' that saves the results of its tests to speed up reconfiguring, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.in' is used to create `configure' by a program called `autoconf'. You only need `configure.in' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. If you're using `csh' on an old version of System V, you might need to type `sh ./configure' instead to prevent `csh' from trying to execute `configure' itself. Running `configure' takes a while. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Type `make install' to install the programs and any data files and documentation. 4. You can remove the program binaries and object files from the source code directory by typing `make clean'. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. You can give `configure' initial values for variables by setting them in the environment. Using a Bourne-compatible shell, you can do that on the command line like this: CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure Or on systems that have the `env' program, you can do it like this: env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you must use a version of `make' that supports the `VPATH' variable, such as GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. If you have to use a `make' that does not supports the `VPATH' variable, you have to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' will install the package's files in `/usr/local/bin', `/usr/local/man', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PATH'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you give `configure' the option `--exec-prefix=PATH', the package will use PATH as the prefix for installing programs and libraries. Documentation and other data files will still use the regular prefix. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Specifying the System Type ========================== There may be some features `configure' can not figure out automatically, but needs to determine by the type of host the package will run on. Usually `configure' can figure that out, but if it prints a message saying it can not guess the host type, give it the `--host=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name with three fields: CPU-COMPANY-SYSTEM See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the host type. If you are building compiler tools for cross-compiling, you can also use the `--target=TYPE' option to select the type of system they will produce code for and the `--build=TYPE' option to select the type of system on which you are compiling the package. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Operation Controls ================== `configure' recognizes the following options to control how it operates. `--cache-file=FILE' Use and save the results of the tests in FILE instead of `./config.cache'. Set FILE to `/dev/null' to disable caching, for debugging `configure'. `--help' Print a summary of the options to `configure', and exit. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--version' Print the version of Autoconf used to generate the `configure' script, and exit. `configure' also accepts some other, not widely useful, options. netgen-4.9.13/ng/0000777000175000001440000000000011377017541010503 500000000000000netgen-4.9.13/ng/parallelfunc.hpp0000644000175000001440000000031411240003500013551 00000000000000#ifndef FILE_PARALLELFUNC #define FILE_PARALLELFUNC void ParallelRun(); void LoadPDEParallel ( const char* filename ); #ifdef NGSOLVE void NGS_ParallelRun ( const string & message); #endif #endif netgen-4.9.13/ng/nghelp.tcl0000644000175000001440000002730611240003500012363 00000000000000proc 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 "Stop 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 } netgen-4.9.13/ng/ngvisual.tcl0000644000175000001440000012466311356017321012760 00000000000000Ng_Vis_Set parameters set viscnt 0 proc snapshottimer { } { after 2000 { snapshottimer } global viscnt set viscnt [expr $viscnt+1] set s1 0000$viscnt # puts $s1 set cnt [string range $s1 [expr [string length $s1]-4] end] set filename "p$cnt.jpg" # puts "cnt = $cnt" # puts "filename = $filename" # .ndraw Ng_SnapShot pictures/$filename } snapshottimer proc redrawtimer { } { global visoptions.autoredraw global visoptions.autoredrawtime set delay [expr int(${visoptions.autoredrawtime}*1000)] if { ${visoptions.autoredraw} == 1 } { redraw; } after $delay { redrawtimer } } redrawtimer set perstarttime [clock clicks -millisecond] proc redrawperiodic { } { global visoptions.redrawperiodic global perstarttime set curtime [clock clicks -millisecond] # puts "redraw periodic, time = $curtime" Ng_Vis_Set time [expr ($curtime - $perstarttime) / 5] redraw if { ${visoptions.redrawperiodic} == 1 } { after 30 { redrawperiodic } }; } proc addplotline { identifier datax datay plotinfo {color black}} { set c $identifier.c set xstart [lindex $plotinfo 0] set ystart [lindex $plotinfo 1] set xmin [lindex $plotinfo 2] set ymin [lindex $plotinfo 3] set unitx [lindex $plotinfo 4] set unity [lindex $plotinfo 5] set latestx [expr ([lindex $datax 0]-$xmin)*$unitx + $xstart] set latesty [expr ([lindex $datay 0]-$ymin)*$unity + $ystart] for {set i 1} {$i < [llength $datax]} {incr i} { set xpos [expr ([lindex $datax $i]-$xmin)*$unitx + $xstart] set ypos [expr ([lindex $datay $i]-$ymin)*$unity + $ystart] $c create line $latestx $latesty $xpos $ypos -width 1 -fill $color set latestx $xpos set latesty $ypos } } proc createlineplot { width height identifier title xmin xmax ymin ymax plotinfo} { set thiswidth $width set thisheight $height if { $thiswidth < 275 } { set thiswidth 275 } if { $thisheight < 225 } { seth thisheight 225 } set w $identifier if {[winfo exists $w] == 1} { wm withdraw $w wm deiconify $w focus $w } { toplevel $w set c $w.c canvas $c -relief raised -width $thiswidth -height $thisheight pack $w.c -side top -fill x set titleFont {Helvetica 18} set smallFont {Helvetica 12} set xstart 100 set xend [expr $thiswidth-75] set ystart [expr $thisheight-75] set yend 75 $c create line $xstart $ystart $xstart $yend -width 2 $c create line $xstart $ystart $xend $ystart -width 2 set unitx [expr double($xend-$xstart)/($xmax-$xmin)] set unity [expr double($yend-$ystart)/($ymax-$ymin)] for {set i 0} {$i <= 1} {set i [expr $i+0.2]} { $c create line [expr $xstart+$i*($xend-$xstart)] [expr $ystart] [expr $xstart+$i*($xend-$xstart)] [expr $ystart+5] -width 2 $c create text [expr $xstart+$i*($xend-$xstart)] [expr $ystart+7] -anchor n -font $smallFont \ -text [format "%.3g" [expr $xmin+$i*($xmax-$xmin)]] $c create line [expr $xstart] [expr $ystart+$i*($yend-$ystart)] [expr $xstart-7] [expr $ystart+$i*($yend-$ystart)] -width 2 $c create text [expr $xstart-9] [expr $ystart+$i*($yend-$ystart)] -anchor e -font $smallFont \ -text [format "%.3g" [expr $ymin+$i*($ymax-$ymin)]] } upvar $plotinfo ploti set ploti "$xstart $ystart $xmin $ymin $unitx $unity" button $w.close -text "Close" -command "destroy $w" pack $w.close wm withdraw $w wm geom $w +100+100 wm deiconify $w wm title $w $title focus $w } } proc getlineplotdata { datax datay xmini xmaxi ymini ymaxi} { upvar $datax datx upvar $datay daty upvar $xmini xmin upvar $xmaxi xmax upvar $ymini ymin upvar $ymaxi ymax global visoptions.lineplotusingx global visoptions.lineplotusingy global visoptions.lineplotsource global visoptions.lineplotfile set datx "" set daty "" set xmin 1e20 set xmax -1e20 set ymin 1e20 set ymax -1e20 if {${visoptions.lineplotsource} == "file"} { set fileId [open ${visoptions.lineplotfile} r] set line "" while {[gets $fileId line] >= 0} { if { [string index [lindex $line 0] 0] != "\#" } { if { ${visoptions.lineplotusingx} < [llength $line] } { lappend datx [lindex $line ${visoptions.lineplotusingx}] if { [lindex $datx end] < $xmin } {set xmin [lindex $datx end]} if { [lindex $datx end] > $xmax } {set xmax [lindex $datx end]} } { lappend datx 0 } if { ${visoptions.lineplotusingy} < [llength $line] } { lappend daty [lindex $line ${visoptions.lineplotusingy}] if { [lindex $daty end] < $ymin } {set ymin [lindex $daty end]} if { [lindex $daty end] > $ymax } {set ymax [lindex $daty end]} } { lappend daty 0 } } } close $fileId } } proc lineplotdialog { } { set w .lineplot_dlg if {[winfo exists .lineplot_dlg] == 1} { wm withdraw $w wm deiconify $w focus $w } { toplevel $w frame $w.filesettings -relief groove -borderwidth 3 frame $w.filesettings.title radiobutton $w.filesettings.title.choose -variable visoptions.lineplotsource \ -value file -text "Data from File" pack $w.filesettings.title.choose -side left pack $w.filesettings.title global visoptions.lineplotselectedeval global visoptions.lineplotfile global visoptions.evaluatefilenames global visoptions.evaluatefiledescriptions set evdata [NGS_GetData evaluatefiles] set visoptions.evaluatefilenames none set visoptions.evaluatefiledescriptions none for {set i 0} {[expr $i+1] < [llength $evdata]} {incr i 2} { lappend visoptions.evaluatefilenames [lindex $evdata $i] lappend visoptions.evaluatefiledescriptions [lindex $evdata [expr $i+1]] } tixOptionMenu $w.filesettings.latestevals -label "Use Evaluate Results: " \ -options { label.width 25 label.anchor e menubutton.width 40 } for {set i 0} {$i < [llength ${visoptions.evaluatefilenames}]} {incr i} { $w.filesettings.latestevals add command $i \ -label "[lindex ${visoptions.evaluatefiledescriptions} $i] ([lindex ${visoptions.evaluatefilenames} $i])" } $w.filesettings.latestevals config -variable visoptions.lineplotselectedeval pack $w.filesettings.latestevals frame $w.filesettings.sfn button $w.filesettings.sfn.bb -text "Browse" \ -command { set visoptions.lineplotfile [tk_getOpenFile] } entry $w.filesettings.sfn.fn -width 50 -relief sunken \ -textvariable visoptions.lineplotfile pack $w.filesettings.sfn.bb $w.filesettings.sfn.fn -side left pack $w.filesettings.sfn button $w.filesettings.refresh -text "Refresh" -command { if { ${visoptions.lineplotselectedeval} != 0} { set visoptions.lineplotfile [lindex ${visoptions.evaluatefilenames} ${visoptions.lineplotselectedeval}] } set saveusingx ${visoptions.lineplotusingx} set saveusingy ${visoptions.lineplotusingy} for { set i 0 } { $i < [llength ${visoptions.lineplotdatadescr}] } { incr i } { ${visoptions.lineplotxcoordselector} delete $i } for { set i 0 } { $i < [llength ${visoptions.lineplotdatadescr}] } { incr i } { ${visoptions.lineplotycoordselector} delete $i } set fileId [open ${visoptions.lineplotfile} r] set line "" gets $fileId line close $fileId if { [lindex $line 0] == "\#nglineplotinfo" } { set visoptions.lineplotdatadescr [lrange $line 1 end] } { set visoptions.lineplotdatadescr "" for { set i 0 } { $i < [llength $line] } { incr i } { lappend visoptions.lineplotdatadescr "data[expr $i+1]" } } for { set i 0 } { $i < [llength ${visoptions.lineplotdatadescr}] } { incr i } { ${visoptions.lineplotxcoordselector} add command $i -label [lindex ${visoptions.lineplotdatadescr} $i] } for { set i 0 } { $i < [llength ${visoptions.lineplotdatadescr}] } { incr i } { ${visoptions.lineplotycoordselector} add command $i -label [lindex ${visoptions.lineplotdatadescr} $i] } if { $saveusingx < [llength ${visoptions.lineplotdatadescr}] } { set visoptions.lineplotusingx $saveusingx } { set visoptions.lineplotusingx 0 } if { $saveusingy < [llength ${visoptions.lineplotdatadescr}] } { set visoptions.lineplotusingy $saveusingy } { set visoptions.lineplotusingy 1 } } pack $w.filesettings.refresh frame $w.filesettings.using global visoptions.lineplotdatadescr tixOptionMenu $w.filesettings.using.xco -label "X-Coord:"\ -options { label.width 8 label.anchor e menubutton.width 15 } for { set i 0 } { $i < [llength ${visoptions.lineplotdatadescr}] } { incr i } { $w.filesettings.using.xco add command $i -label [lindex ${visoptions.lineplotdatadescr} $i] } $w.filesettings.using.xco config -variable visoptions.lineplotusingx tixOptionMenu $w.filesettings.using.yco -label "Y-Coord:"\ -options { label.width 8 label.anchor e menubutton.width 15 } for { set i 0 } { $i < [llength ${visoptions.lineplotdatadescr}] } { incr i } { $w.filesettings.using.yco add command $i -label [lindex ${visoptions.lineplotdatadescr} $i] } $w.filesettings.using.yco config -variable visoptions.lineplotusingy global visoptions.lineplotxcoordselector global visoptions.lineplotycoordselector set visoptions.lineplotxcoordselector $w.filesettings.using.xco set visoptions.lineplotycoordselector $w.filesettings.using.yco pack $w.filesettings.using.xco $w.filesettings.using.yco -side left pack $w.filesettings.using pack $w.filesettings -fill x -ipady 3 frame $w.settings -relief groove -borderwidth 3 label $w.settings.title -text "\nSettings\n" pack $w.settings.title frame $w.settings.minmax checkbutton $w.settings.minmax.autoscale -text "Autoscale" -variable visoptions.lineplotautoscale tixControl $w.settings.minmax.xmin -label "Min. x: " \ -integer false -variable visoptions.lineplotxmin \ -options { entry.width 6 label.width 8 label.anchor e } tixControl $w.settings.minmax.xmax -label "Max. x: " \ -integer false -variable visoptions.lineplotxmax \ -options { entry.width 6 label.width 8 label.anchor e } tixControl $w.settings.minmax.ymin -label "Min. y: " \ -integer false -variable visoptions.lineplotymin \ -options { entry.width 6 label.width 8 label.anchor e } tixControl $w.settings.minmax.ymax -label "Max. y: " \ -integer false -variable visoptions.lineplotymax \ -options { entry.width 6 label.width 8 label.anchor e } pack $w.settings.minmax.autoscale $w.settings.minmax.xmin $w.settings.minmax.xmax \ $w.settings.minmax.ymin $w.settings.minmax.ymax -side left pack $w.settings.minmax label $w.settings.empty1 -text "" pack $w.settings.empty1 frame $w.settings.plotsize tixControl $w.settings.plotsize.xsize -label "Plotsize x: "\ -integer true -variable visoptions.lineplotsizex \ -options { entry.width 6 label.width 13 label.anchor e } tixControl $w.settings.plotsize.ysize -label "y: "\ -integer true -variable visoptions.lineplotsizey \ -options { entry.width 6 label.width 3 label.anchor e } pack $w.settings.plotsize.xsize $w.settings.plotsize.ysize -side left pack $w.settings.plotsize label $w.settings.empty2 -text "" pack $w.settings.empty2 tixOptionMenu $w.settings.color -label "Linecolor: " \ -options { label.width 19 label.anchor e menubutton.width 15 } foreach step { red black blue green yellow } { $w.settings.color add command $step -label $step } $w.settings.color config -variable visoptions.lineplotcolor pack $w.settings.color pack $w.settings set datax "" set datay "" set xmin 0 set xmax 0 set ymin 0 set ymax 0 frame $w.plots -relief groove -borderwidth 3 tixOptionMenu $w.plots.selplot -label "Selected Plot: " \ -options { label.width 19 label.anchor e menubutton.width 15 } $w.plots.selplot add command none -label "None" $w.plots.selplot config -variable visoptions.lineplotselected global visoptions.lineplotselector set visoptions.lineplotselector $w.plots.selplot button $w.plots.new -text "Generate New Plot" -command { if { ${visoptions.lineplotselectedeval} != 0} { set visoptions.lineplotfile [lindex ${visoptions.evaluatefilenames} ${visoptions.lineplotselectedeval}] } getlineplotdata datax datay xmin xmax ymin ymax puts stdout "xmin $xmin xmax $xmax ymin $ymin ymax $ymax" global visoptions.lineplotautoscale if {! ${visoptions.lineplotautoscale}} { puts "using set min/max values" set xmin ${visoptions.lineplotxmin} set xmax ${visoptions.lineplotxmax} set ymin ${visoptions.lineplotymin} set ymax ${visoptions.lineplotymax} } incr visoptions.lineplotcurrentnum set ident .newplot${visoptions.lineplotcurrentnum} set plotinfo "" createlineplot ${visoptions.lineplotsizex} ${visoptions.lineplotsizey} \ $ident "Lineplot ${visoptions.lineplotcurrentnum}" \ $xmin $xmax $ymin $ymax plotinfo lappend visoptions.lineplotinfos $plotinfo ${visoptions.lineplotselector} add command ${visoptions.lineplotcurrentnum} -label "Lineplot ${visoptions.lineplotcurrentnum}" addplotline $ident $datax $datay $plotinfo ${visoptions.lineplotcolor} } button $w.plots.addto -text "Add to Selected Plot" -command { if { ${visoptions.lineplotselectedeval} != 0} { set visoptions.lineplotfile [lindex ${visoptions.evaluatefilenames} ${visoptions.lineplotselectedeval}] } if { ${visoptions.lineplotselected} != "none" } { getlineplotdata datax datay xmin xmax ymin ymax set ident .newplot${visoptions.lineplotselected} set plotinfo [lindex ${visoptions.lineplotinfos} ${visoptions.lineplotselected}] addplotline $ident $datax $datay $plotinfo ${visoptions.lineplotcolor} } } pack $w.plots.new $w.plots.addto $w.plots.selplot pack $w.plots -fill x -ipady 3 button $w.close -text "Close" -command "destroy $w" pack $w.close wm withdraw $w wm geom $w +200+100 wm deiconify $w wm title $w "2D Lineplots" focus $w } } set fieldlinesdialog_pop1 0 proc fieldlinesdialog { } { set w .fieldlines_dlg global fieldlinesdialog_pop1 set fieldlinesdialog_pop1 1 if {[winfo exists .fieldlines_dlg] == 1} { wm withdraw $w wm deiconify $w focus $w } { toplevel $w tixNoteBook $w.nb -ipadx 6 -ipady 6 $w.nb add draw -label "Draw" $w.nb add settings -label "Settings" pack $w.nb -expand yes -fill both -padx 5 -pady 5 -side top # Main Window set f [$w.nb subwidget draw] frame $f.general checkbutton $f.general.enable -text "Enable Fieldlines" \ -variable visoptions.drawfieldlines \ -command { # set visoptions.redrawperiodic ${visoptions.drawfieldlines} # redrawperiodic # redrawperiodic # sonst Ng_Vis_Set parameters; redraw } tixControl $f.general.num -label "Num: " -integer true \ -variable visoptions.numfieldlines \ -command { Ng_Vis_Set parameters; redraw } \ -options { entry.width 6 label.width 12 label.anchor e } pack $f.general.enable $f.general.num -side left pack $f.general label $f.labe0 -text " " pack $f.labe0 frame $f.general1 checkbutton $f.general1.randomstart -text "Field dependent density " \ -variable visoptions.fieldlinesrandomstart \ -command { Ng_Vis_Set parameters; redraw} checkbutton $f.general1.redrawperiodic -text "Animate periodic" \ -variable visoptions.redrawperiodic \ -command { redrawperiodic Ng_Vis_Set parameters; redraw } pack $f.general1.randomstart $f.general1.redrawperiodic -side left pack $f.general1 label $f.lab0 -text " " pack $f.lab0 tixOptionMenu $f.vecfun -label "Vector Function: " \ -options { label.width 18 label.anchor e menubutton.width 12 } $f.vecfun add command none -label None for { set i 1 } { $i <= [Ng_Vis_Field getnfieldnames] } { incr i } { set fname [Ng_Vis_Field getfieldname $i] set fcomp [Ng_Vis_Field getfieldcomponents $i] set iscomplex [Ng_Vis_Field iscomplex $i] set sdim [Ng_Vis_Field getdimension] if { $iscomplex == 1 } { set fcomp [expr $fcomp / 2] } if { ($fcomp == $sdim) || ($fcomp == 3) } { $f.vecfun add command $fname -label $fname } } $f.vecfun configure -variable visoptions.fieldlinesvecfunction $f.vecfun configure -command { Ng_Vis_Set parameters; redraw } pack $f.vecfun label $f.lab00 -text " " pack $f.lab00 frame $f.phasesettings checkbutton $f.phasesettings.onephase -text "Fix Phase" -variable visoptions.fieldlinesonlyonephase scale $f.phasesettings.phase -orient horizontal -length 300 -from 0 -to 360 \ -label "phi" \ -resolution 1 \ -variable visoptions.fieldlinesphase \ -command { popupcheckredraw3 fieldlinesdialog_pop1 } pack $f.phasesettings.onephase $f.phasesettings.phase -side left pack $f.phasesettings label $f.lab1 -text " " pack $f.lab1 frame $f.boxsettings -relief groove -borderwidth 3 frame $f.boxsettings.title radiobutton $f.boxsettings.title.choose -variable visoptions.fieldlinesstartarea \ -value box -text "Startpoints in Box" pack $f.boxsettings.title.choose -side left pack $f.boxsettings.title frame $f.boxsettings.points label $f.boxsettings.points.lab2 -text "Pmin"; entry $f.boxsettings.points.ent1x -width 8 -relief sunken \ -textvariable visoptions.fieldlinesstartareap1x entry $f.boxsettings.points.ent1y -width 8 -relief sunken \ -textvariable visoptions.fieldlinesstartareap1y entry $f.boxsettings.points.ent1z -width 8 -relief sunken \ -textvariable visoptions.fieldlinesstartareap1z label $f.boxsettings.points.lab3 -text " Pmax"; entry $f.boxsettings.points.ent2x -width 8 -relief sunken \ -textvariable visoptions.fieldlinesstartareap2x entry $f.boxsettings.points.ent2y -width 8 -relief sunken \ -textvariable visoptions.fieldlinesstartareap2y entry $f.boxsettings.points.ent2z -width 8 -relief sunken \ -textvariable visoptions.fieldlinesstartareap2z pack $f.boxsettings.points pack $f.boxsettings.points.lab2 $f.boxsettings.points.ent1x $f.boxsettings.points.ent1y $f.boxsettings.points.ent1z -side left pack $f.boxsettings.points.lab3 $f.boxsettings.points.ent2x $f.boxsettings.points.ent2y $f.boxsettings.points.ent2z -side left button $f.boxsettings.settobb -text "Bounding Box" -command { set bbox [Ng_MeshInfo bbox] set visoptions.fieldlinesstartareap1x [lindex $bbox 0] set visoptions.fieldlinesstartareap2x [lindex $bbox 1] set visoptions.fieldlinesstartareap1y [lindex $bbox 2] set visoptions.fieldlinesstartareap2y [lindex $bbox 3] set visoptions.fieldlinesstartareap1z [lindex $bbox 4] set visoptions.fieldlinesstartareap2z [lindex $bbox 5] } pack $f.boxsettings.settobb pack $f.boxsettings -fill x -ipady 3 frame $f.facesettings -relief groove -borderwidth 3 frame $f.facesettings.title radiobutton $f.facesettings.title.choose -variable visoptions.fieldlinesstartarea \ -value face -text "Startpoints on Face" pack $f.facesettings.title.choose -side left pack $f.facesettings.title frame $f.facesettings.index label $f.facesettings.index.lab -text "face index:" label $f.facesettings.index.ent -text 1 -padx 4 pack $f.facesettings.index.lab $f.facesettings.index.ent -side left pack $f.facesettings.index pack $f.facesettings -fill x -ipady 3 global visoptions.fieldlinesfilename frame $f.filesettings -relief groove -borderwidth 3 frame $f.filesettings.title radiobutton $f.filesettings.title.choose -variable visoptions.fieldlinesstartarea \ -value file -text "Startpoints from File" pack $f.filesettings.title.choose -side left pack $f.filesettings.title frame $f.filesettings.sfn button $f.filesettings.sfn.bb -text "Browse" \ -command { set types { { "Netgen Fieldlines" {.nef} } } set visoptions.fieldlinesfilename [tk_getOpenFile -filetypes $types -defaultextension ".nef"] } entry $f.filesettings.sfn.fn -width 50 -relief sunken \ -textvariable visoptions.fieldlinesfilename pack $f.filesettings.sfn.bb $f.filesettings.sfn.fn -side left pack $f.filesettings.sfn pack $f.filesettings -fill x -ipady 3 # Settings set g [$w.nb subwidget settings] frame $g.linesettings -relief groove -borderwidth 3 label $g.linesettings.title -text "\nLine Settings\n" tixControl $g.linesettings.length -label "rel. Length: " -integer false \ -variable visoptions.fieldlineslength -min 0.00001 -max 10000 -step 0.1 \ -options { entry.width 6 label.width 25 label.anchor e } tixControl $g.linesettings.maxpoints -label "max. Points: " -integer true \ -variable visoptions.fieldlinesmaxpoints -min 0 -max 10000 -step 1 \ -options { entry.width 6 label.width 25 label.anchor e } tixControl $g.linesettings.thick -label "rel. Thickness: " -integer false \ -variable visoptions.fieldlinesthickness -min 1e-10 -max 0.5 -step 0.001 \ -options { entry.width 6 label.width 25 label.anchor e } pack $g.linesettings.title $g.linesettings.length $g.linesettings.maxpoints $g.linesettings.thick pack $g.linesettings -fill x -ipady 3 global visoptions.fieldlinestolerance frame $g.odesettings -relief groove -borderwidth 3 label $g.odesettings.title -text "\nODE Settings\n" tixControl $g.odesettings.tol -label "rel. Tolerance: " -integer false \ -variable visoptions.fieldlinestolerance -min 0.00001 -max 1 -step 0.01 \ -options { entry.width 6 label.width 25 label.anchor e } tixOptionMenu $g.odesettings.rktype -label "RK-Type " \ -options { label.width 20 label.anchor e menubutton.width 25 } $g.odesettings.rktype add command euler -label "Euler, order 1" $g.odesettings.rktype add command eulercauchy -label "Euler-Cauchy, order 2" $g.odesettings.rktype add command simpson -label "Simpson, order 3" $g.odesettings.rktype add command crungekutta -label "classical Runge-Kutta, order 4" $g.odesettings.rktype configure -variable visoptions.fieldlinesrktype $g.odesettings.rktype configure -command { Ng_Vis_Set parameters; redraw } pack $g.odesettings.title $g.odesettings.tol $g.odesettings.rktype pack $g.odesettings -fill x -ipady 3 # buttons frame $w.bu pack $w.bu button $w.bu.calc -text "Build Fieldlines" -command { if { ${visoptions.fieldlinesvecfunction} == "none" } { bgerror "Please select the vector function first!" } { set visoptions.drawfieldlines 1 Ng_Vis_Set parameters Ng_BuildFieldLines redraw } } button $w.bu.help -text "Help" -command { if {[winfo exists .fieldlines_help] == 1} { wm withdraw .fieldlines_help wm deiconify .fieldlines_help focus .fieldlines_help } { toplevel .fieldlines_help tixScrolledText .fieldlines_help.ht -scrollbar y set text [.fieldlines_help.ht subwidget text] $text configure -setgrid true -wrap word $text tag configure bold -font *-*-bold-*-*-*-* $text insert end \ "Draw menu\n \n" bold $text insert end \ "Enable Fieldlines\n To turn on and off the calculated fieldlines. (Has to be turned on to start the calculation)\n" $text insert end \ "Num\n Number of fieldlines to calculate. (May not be used exactly.)" $text insert end \ "Field dependent density\n There will be more fieldline startpoints where the field is stronger\n\n" $text insert end \ "Animate periodic\n (for quasistationary fields) The fieldlines of the different phase angles are animated.\n ATTENTION: \"Fix Phase\" has to be turned off\n\n" $text insert end \ "Vector Function\n The function fixing the direction of the lines\n\n" $text insert end \ "Fix Phase\n (for quasistationary fields) Only calculate and draw fieldlines for one special phase angle.\n\n" $text insert end \ "Startpoints in Box\n Set the startpoints inside the box \[Pmin1,Pmax1\] x \[Pmin2,Pmax2\] x \[Pmin3,Pmax3\]\n" $text insert end \ " With the button \"Bounding Box\" the whole bounding box of the geometry is selected.\n\n" $text insert end \ "Startpoints on Face\n All startpoints will be set on one face. This face is selected by double-clicking with the mouse.\n\n" $text insert end \ "Startpoints from File\n The startpoint information will be read from the selected file.\n The entries in the file can be as follows:\n" $text insert end \ " point \n set a (potential) startpoint\n" $text insert end \ " line \n set n (potential) startpoints on the line from (x1,y1,z1) to (x2,y2,z2)\n" $text insert end \ " box \n set n (potential) startpoints inside the box \[x1,x2\] x \[y1,y2\] x \[z1,z2\]\n" $text insert end \ " ATTENTION: These are potential startpoints.\n The total number of startpoints will be bounded by the \"Num\"-parameter.\n \n \n \n" $text insert end \ "Settings Menu\n \n" bold $text insert end \ "rel. Length\n The maximal length of a fieldline relative to the diameter of the geometry.\n\n" $text insert end \ "max. Points\n The maximum number of Runge-Kutta steps.\n\n" $text insert end \ "rel. Thickness\n The thickness of the fieldlines relative to the diameter of the geometry.\n\n" $text insert end \ "rel. Tolerance\n The tolerance for the step-length control of the Runge-Kutta method.\n\n" $text insert end \ "RK-Type\n Which Runge-Kutta scheme to use\n \n \n \n" $text insert end \ "Button \"Build Fieldlines\"\n" bold $text insert end \ " Build the fieldlines." $text configure -state disabled pack .fieldlines_help.ht -expand yes -fill both wm withdraw .fieldlines_help wm geom .fieldlines_help +300+200 wm deiconify .fieldlines_help wm title .fieldlines_help "Fieldlines Help" focus .fieldlines_help } } button $w.bu.cancel -text "Done" -command "destroy $w" pack $w.bu.calc $w.bu.help $w.bu.cancel -side left -expand yes wm withdraw $w wm geom $w +200+100 wm deiconify $w wm title $w "Fieldlines" # grab $w focus $w } global visoptions.fieldlinesstartface set f [$w.nb subwidget draw] set visoptions.fieldlinesstartface [Ng_BCProp getactive] $f.facesettings.index.ent configure -text ${visoptions.fieldlinesstartface} } #proc popupcheckredraw { vari { x 0 } } { # upvar $vari varname # if { $varname == 1 } { # set varname 0 # } { # Ng_Vis_Set parameters # redraw # } #} set visual_dialog_pop1 0 set visual_dialog_pop2 0 set visual_dialog_pop3 0 set visual_dialog_pop4 0 set visual_dialog_pop5 0 set visual_dialog_pop6 0 set visual_dialog_pop7 0 proc visual_dialog { } { set w .visoptions_dlg global visual_dialog_pop1 global visual_dialog_pop2 global visual_dialog_pop3 global visual_dialog_pop4 global visual_dialog_pop5 global visual_dialog_pop6 global visual_dialog_pop7 set visual_dialog_pop1 1 set visual_dialog_pop2 1 set visual_dialog_pop3 1 set visual_dialog_pop4 1 set visual_dialog_pop5 1 set visual_dialog_pop6 1 set visual_dialog_pop7 1 if {[winfo exists .visoptions_dlg] == 1} { wm withdraw $w wm deiconify $w focus $w } { toplevel $w frame $w.grid -relief groove -borderwidth 3 # change to: max gridsize 200 scale $w.grid.size -orient horizontal -length 100 -from 1 -to 200 \ -label "Grid" \ -resolution 1 \ -variable visoptions.gridsize \ -command { popupcheckredraw visual_dialog_pop2 } # x- and y- offset scale $w.grid.xoffset -orient horizontal -length 80 -from 0 -to 1 \ -label "x-Offset" \ -resolution 0.05 \ -variable visoptions.xoffset \ -command { popupcheckredraw visual_dialog_pop3 } scale $w.grid.yoffset -orient horizontal -length 80 -from 0 -to 1 \ -label "y-Offset" \ -resolution 0.05 \ -variable visoptions.yoffset \ -command { popupcheckredraw visual_dialog_pop4 } # pack $w.showclipsolution pack $w.grid -fill x -ipady 3 pack $w.grid.size $w.grid.xoffset $w.grid.yoffset -side left -expand yes # pack $w.lineartexture $w.numcols frame $w.deform -relief groove -borderwidth 3 checkbutton $w.deform.cb -text "Deformation" \ -variable visoptions.deformation \ -command { Ng_Vis_Set parameters; redraw } tixControl $w.deform.sc1 -label "Scale: " -integer false \ -variable visoptions.scaledeform1 \ -command { Ng_Vis_Set parameters; redraw } \ -options { entry.width 6 label.width 7 label.anchor e } scale $w.deform.sc2 -orient horizontal -length 100 -from 0 -to 1 \ -resolution 0.01 \ -variable visoptions.scaledeform2 \ -command { popupcheckredraw visual_dialog_pop5 } pack $w.deform -fill x -ipady 2 pack $w.deform.cb $w.deform.sc1 $w.deform.sc2 -side left -expand yes frame $w.as -relief groove -borderwidth 3 checkbutton $w.as.autoscale -text "Autoscale" \ -variable visoptions.autoscale \ -command { Ng_Vis_Set parameters; redraw } tixControl $w.as.minval -label "Min-value: " -integer false \ -variable visoptions.mminval \ -command { Ng_Vis_Set parametersrange; redraw } \ -options { entry.width 6 label.width 12 label.anchor e } tixControl $w.as.maxval -label "Max-value: " -integer false \ -variable visoptions.mmaxval \ -command { Ng_Vis_Set parametersrange; redraw } \ -options { entry.width 6 label.width 12 label.anchor e } pack $w.as -fill x -ipady 3 pack $w.as.autoscale $w.as.minval $w.as.maxval -side left frame $w.iso -relief groove -borderwidth 3 pack $w.iso -fill x -ipady 3 frame $w.iso.cb pack $w.iso.cb -side left checkbutton $w.iso.cb.isolines -text "Iso-lines" \ -variable visoptions.isolines \ -command { Ng_Vis_Set parameters; redraw } pack $w.iso.cb.isolines -side top checkbutton $w.iso.cb.isosurf -text "Iso-Surface" \ -variable visoptions.isosurf \ -command { Ng_Vis_Set parameters; redraw } pack $w.iso.cb.isosurf -side top scale $w.iso.numiso -orient horizontal -length 100 -from 2 -to 50 \ -label "" \ -resolution 1 \ -variable visoptions.numiso \ -command { popupcheckredraw visual_dialog_pop6 } pack $w.iso.numiso -side left # scale $w.iso.subdiv -orient horizontal -length 100 -from 0 -to 5 \ # -label "subdivision" \ # -resolution 1 \ # -variable visoptions.subdivisions \ # -command { popupcheckredraw visual_dialog_pop7 } # # -command { puts "subdiv-vis"; Ng_Vis_Set parameters; puts "cal redraw"; redraw } frame $w.iso.subdiv radiobutton $w.iso.subdiv.zero -text "0" -variable visoptions.subdivisions -value 0 \ -command { #set visoptions.subdivisions 1; Ng_Vis_Set parameters; redraw; } radiobutton $w.iso.subdiv.one -text "1" -variable visoptions.subdivisions -value 1 \ -command { #set visoptions.subdivisions 1; Ng_Vis_Set parameters; redraw; } radiobutton $w.iso.subdiv.two -text "2" -variable visoptions.subdivisions -value 2 \ -command { #set visoptions.subdivisions 2; Ng_Vis_Set parameters; redraw; } radiobutton $w.iso.subdiv.three -text "3" -variable visoptions.subdivisions -value 3 \ -command { #set visoptions.subdivisions 3; Ng_Vis_Set parameters; redraw; } radiobutton $w.iso.subdiv.four -text "4" -variable visoptions.subdivisions -value 4 \ -command { #set visoptions.subdivisions 4; Ng_Vis_Set parameters; redraw; } radiobutton $w.iso.subdiv.five -text "5" -variable visoptions.subdivisions -value 5 \ -command { #set visoptions.subdivisions 5; Ng_Vis_Set parameters; redraw; } label $w.iso.subdiv.text -text "subdivision" pack $w.iso.subdiv -side right -ipadx 10 # ; Ng_SetNextTimeStamp pack $w.iso.subdiv.text -side top pack $w.iso.subdiv.zero $w.iso.numiso -side left pack $w.iso.subdiv.one $w.iso.numiso -side left pack $w.iso.subdiv.two $w.iso.numiso -side left pack $w.iso.subdiv.three $w.iso.numiso -side left pack $w.iso.subdiv.four $w.iso.numiso -side left pack $w.iso.subdiv.five $w.iso.numiso -side left # scale $w.iso.zpos -orient horizontal -length 100 -from 0 -to 1 \ # -label "z-position" \ # -resolution 0.01 \ # -variable visoptions.zposition \ # -command { # catch {NGS_Set zpos ${visoptions.zposition};} # redraw } # pack $w.iso.zpos -side right frame $w.redraw -relief groove -borderwidth 3 checkbutton $w.redraw.auto -text "Auto-redraw" \ -variable visoptions.autoredraw tixControl $w.redraw.val -label " after (sec) " -integer false \ -variable visoptions.autoredrawtime \ -options { entry.width 6 label.width 0 label.anchor w } pack $w.redraw -fill x -ipady 3 pack $w.redraw.auto $w.redraw.val -side left tixControl $w.redraw.simtime -label " Simulation Time (1e-6 s)" -integer false \ -variable visoptions.simulationtime \ -command { Ng_Vis_Set time ${visoptions.simulationtime}; catch {NGS_Set time ${visoptions.simulationtime};} redraw } \ -options { entry.width 6 label.width 0 label.anchor w } pack $w.redraw.simtime -side left tixOptionMenu $w.clipsol -label "Clipping Plane Sol: " \ -options { label.width 18 label.anchor e menubutton.width 12 } set none 1 $w.clipsol add command none -label None $w.clipsol add command scal -label "Scalar Function" $w.clipsol add command vec -label "Vector Function" $w.clipsol configure -variable visoptions.clipsolution $w.clipsol configure -command { Ng_Vis_Set parameters; redraw } pack $w.clipsol tixOptionMenu $w.scalfun -label "Scalar Function: " \ -options { label.width 18 label.anchor e menubutton.width 12 } tixOptionMenu $w.vecfun -label "Vector Function: " \ -options { label.width 18 label.anchor e menubutton.width 12 } $w.scalfun add command none -label None for { set i 1 } { $i <= [Ng_Vis_Field getnfieldnames] } { incr i } { set fname [Ng_Vis_Field getfieldname $i] set fcomp [Ng_Vis_Field getfieldcomponents $i] if { $fcomp == 1 } { $w.scalfun add command $fname.1 -label $fname } { for { set j 1 } { $j <= $fcomp } { incr j } { $w.scalfun add command $fname.$j -label "$fname ($j)" } $w.scalfun add command $fname.0 -label "func ($fname)" } } $w.vecfun add command none -label None for { set i 1 } { $i <= [Ng_Vis_Field getnfieldnames] } { incr i } { set fname [Ng_Vis_Field getfieldname $i] set fcomp [Ng_Vis_Field getfieldcomponents $i] set iscomplex [Ng_Vis_Field iscomplex $i] set sdim [Ng_Vis_Field getdimension] if { $iscomplex == 1 } { set fcomp [expr $fcomp / 2] } if { ($fcomp == $sdim) || ($fcomp == 3) } { $w.vecfun add command $fname -label $fname } } $w.scalfun configure -variable visoptions.scalfunction $w.scalfun configure -command { Ng_Vis_Set parameters; redraw } $w.vecfun configure -variable visoptions.vecfunction $w.vecfun configure -command { Ng_Vis_Set parameters; redraw } tixOptionMenu $w.evaluate -label "Evaluate: " \ -options { label.width 18 label.anchor e menubutton.width 12 } $w.evaluate add command abs -label "|.|" $w.evaluate add command abstens -label "|tensor|" $w.evaluate add command mises -label "Mises" $w.evaluate add command main -label "Main" $w.evaluate configure -variable visoptions.evaluate $w.evaluate configure -command { Ng_Vis_Set parameters; redraw } pack $w.scalfun $w.vecfun $w.evaluate tixControl $w.multidimcomp -label "multidim-component: " -integer true \ -variable visoptions.multidimcomponent -min 0 \ -command { Ng_Vis_Set parameters; redraw } \ -options { entry.width 6 label.width 18 label.anchor e } pack $w.multidimcomp checkbutton $w.showsurfsolution -text "Draw Surface Vectors" \ -variable visoptions.showsurfacesolution \ -command { Ng_Vis_Set parameters; redraw } checkbutton $w.showcurves -text "Show Curves" \ -variable visoptions.drawpointcurves \ -command { Ng_Vis_Set parameters; redraw } checkbutton $w.imaginary -text "Imaginary Part" \ -variable visoptions.imaginary \ -command { Ng_Vis_Set parameters; redraw } checkbutton $w.logscale -text "Log Scale" \ -variable visoptions.logscale \ -command { Ng_Vis_Set parameters; redraw } checkbutton $w.invcolor -text "Inverse Color" \ -variable visoptions.invcolor \ -command { Ng_Vis_Set parametersrange; redraw } frame $w.texframe checkbutton $w.texframe.usetexture -text "Use Textures (" \ -variable visoptions.usetexture \ -command { Ng_Vis_Set parameters; redraw } checkbutton $w.texframe.lintexture -text "Linear )" \ -variable visoptions.lineartexture \ -command { Ng_Vis_Set parametersrange; redraw } checkbutton $w.lineartexture -text "Use Linear Texture" \ -variable visoptions.lineartexture \ -command { Ng_Vis_Set parameters; redraw } scale $w.numcols -orient horizontal -length 100 -from 0 -to 50 \ -resolution 1 \ -variable visoptions.numtexturecols \ -command { popupcheckredraw visual_dialog_pop1 } checkbutton $w.showclipsolution -text "Draw Clipping Plane Solution" \ -variable visoptions.showclipsolution \ -command { Ng_Vis_Set parameters; redraw } checkbutton $w.redrawperiodic -text "Animate periodic" \ -variable visoptions.redrawperiodic \ -command { redrawperiodic Ng_Vis_Set parameters; redraw } pack $w.showsurfsolution $w.showcurves pack $w.imaginary $w.logscale $w.texframe $w.invcolor $w.redrawperiodic pack $w.texframe.usetexture $w.texframe.lintexture -side left -expand yes frame $w.bu pack $w.bu -pady 5 button $w.bu.showsol -text "Show Solution" -command { set selectvisual solution Ng_SetVisParameters redraw } button $w.bu.clipping -text "Clipping" -command { clippingdialog; } button $w.bu.fieldlines -text "Fieldlines" -command { fieldlinesdialog; } button $w.bu.lineplot -text "2D Lineplot" -command { lineplotdialog; } button $w.bu.done -text "Close" -command { destroy .visoptions_dlg } pack $w.bu.showsol $w.bu.clipping $w.bu.fieldlines $w.bu.lineplot $w.bu.done -side left -expand yes wm withdraw $w wm geom $w +100+100 wm deiconify $w wm title $w "Visualization" } } proc reset_visual_dialog { } { set w .visoptions_dlg if {[winfo exists .visoptions_dlg] == 1} { destroy $w.scalfun $w.vecfun $w.evaluate $w.multidimcomp destroy $w.imaginary $w.logscale $w.texframe.usetexture $w.texframe.lintexture destroy $w.texframe destroy $w.invcolor $w.redrawperiodic destroy $w.bu -pady 5 destroy $w.bu.showsol $w.bu.clipping $w.bu.fieldlines $w.bu.lineplot $w.bu.done -side left -expand yes checkbutton $w.imaginary -text "Imaginary Part" \ -variable visoptions.imaginary \ -command { Ng_Vis_Set parameters; redraw } frame $w.texframe checkbutton $w.texframe.usetexture -text "Use Textures (" \ -variable visoptions.usetexture \ -command { Ng_Vis_Set parameters; redraw } checkbutton $w.texframe.lintexture -text "Linear )" \ -variable visoptions.lineartexture \ -command { Ng_Vis_Set parameters; redraw } checkbutton $w.invcolor -text "Inverse Color" \ -variable visoptions.invcolor \ -command { Ng_Vis_Set parameters; redraw } checkbutton $w.logscale -text "Log Scale" \ -variable visoptions.logscale \ -command { Ng_Vis_Set parameters; redraw } checkbutton $w.redrawperiodic -text "Animate periodic" \ -variable visoptions.redrawperiodic \ -command { redrawperiodic Ng_Vis_Set parameters; redraw } tixOptionMenu $w.scalfun -label "Scalar Function: " \ -options { label.width 18 label.anchor e menubutton.width 12 } tixOptionMenu $w.vecfun -label "Vector Function: " \ -options { label.width 18 label.anchor e menubutton.width 12 } $w.scalfun add command none -label None for { set i 1 } { $i <= [Ng_Vis_Field getnfieldnames] } { incr i } { set fname [Ng_Vis_Field getfieldname $i] set fcomp [Ng_Vis_Field getfieldcomponents $i] if { $fcomp == 1 } { $w.scalfun add command $fname.1 -label $fname } { for { set j 1 } { $j <= $fcomp } { incr j } { $w.scalfun add command $fname.$j -label "$fname ($j)" } $w.scalfun add command $fname.0 -label "func ($fname)" } } $w.vecfun add command none -label None for { set i 1 } { $i <= [Ng_Vis_Field getnfieldnames] } { incr i } { set fname [Ng_Vis_Field getfieldname $i] set fcomp [Ng_Vis_Field getfieldcomponents $i] set iscomplex [Ng_Vis_Field iscomplex $i] set sdim [Ng_Vis_Field getdimension] if { $iscomplex == 1 } { set fcomp [expr $fcomp / 2] } if { ($fcomp == $sdim) || ($fcomp == 3) } { $w.vecfun add command $fname -label $fname } } $w.scalfun configure -variable visoptions.scalfunction $w.scalfun configure -command { Ng_Vis_Set parameters; redraw } $w.vecfun configure -variable visoptions.vecfunction $w.vecfun configure -command { Ng_Vis_Set parameters; redraw } # puts "sclfunction = ${visoptions.scalfunction}" tixOptionMenu $w.evaluate -label "Evaluate: " \ -options { label.width 18 label.anchor e menubutton.width 12 } $w.evaluate add command abs -label "|.|" $w.evaluate add command abstens -label "|tensor|" $w.evaluate add command mises -label "Mises" $w.evaluate add command main -label "Main" $w.evaluate configure -variable visoptions.evaluate $w.evaluate configure -command { Ng_Vis_Set parameters; redraw } pack $w.scalfun $w.vecfun $w.evaluate tixControl $w.multidimcomp -label "multidim-component: " -integer true \ -variable visoptions.multidimcomponent -min 0 \ -command { Ng_Vis_Set parameters; redraw } \ -options { entry.width 6 label.width 18 label.anchor e } pack $w.multidimcomp pack $w.imaginary $w.logscale $w.texframe $w.invcolor $w.redrawperiodic pack $w.texframe.usetexture $w.texframe.lintexture -side left -expand yes frame $w.bu pack $w.bu -pady 5 button $w.bu.showsol -text "Show Solution" -command { set selectvisual solution Ng_SetVisParameters redraw } button $w.bu.clipping -text "Clipping" -command { clippingdialog; } button $w.bu.fieldlines -text "Fieldlines" -command { fieldlinesdialog; } button $w.bu.lineplot -text "2D Lineplot" -command { lineplotdialog; } button $w.bu.done -text "Close" -command { destroy .visoptions_dlg } pack $w.bu.showsol $w.bu.clipping $w.bu.fieldlines $w.bu.lineplot $w.bu.done -side left -expand yes wm withdraw $w wm deiconify $w } } netgen-4.9.13/ng/Makefile.am0000644000175000001440000000321511375223126012450 00000000000000include_HEADERS = AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include -I$(top_srcdir)/libsrc/interface -DOPENGL -D$(TOGL_WINDOWINGSYSTEM) $(OCCFLAGS) $(TCL_INCLUDES) $(MPI_INCLUDES) $(FFMPEG_INCLUDES) $(JPEGLIB_INCLUDES) bin_PROGRAMS = netgen netgen_SOURCES = demoview.cpp ngappinit.cpp ngpkg.cpp onetcl.cpp nginterface.cpp nginterface_v2.cpp parallelfunc.cpp parallelinterface.cpp demoview.hpp parallelfunc.hpp togl_1_7.h netgen_LDADD = $(top_builddir)/libsrc/visualization/libvisual.a \ $(top_builddir)/libsrc/csg/libcsg.la \ $(top_builddir)/libsrc/geom2d/libgeom2d.la \ $(top_builddir)/libsrc/interface/libinterface.la \ $(top_builddir)/libsrc/stlgeom/libstl.la \ $(top_builddir)/libsrc/occ/libocc.la \ $(top_builddir)/libsrc/meshing/libmesh.la \ $(top_builddir)/libsrc/gprim/libgprim.la \ $(top_builddir)/libsrc/linalg/libla.la \ $(top_builddir)/libsrc/general/libgen.la \ $(OCCLIBS) -L$(TK_BIN_DIR)/Togl1.7 $(TOGLLIBDIR) -lTogl1.7 $(LIBGLU) $(TK_LIB_SPEC) $(TCL_LIB_SPEC) $(MPI_LIBS) $(FFMPEG_LIBS) $(JPEGLIB_LIBS) $(PKG_LIBS) # add for static linkage of ngsolve: # /opt/netgen/lib/libngsolve.a /opt/netgen/lib/libngcomp.a /opt/netgen/lib/libngcomp.a /opt/netgen/lib/libngfemng.a /opt/netgen/lib/libngmg.a /opt/netgen/lib/libngla.a /opt/netgen/lib/libngbla.a /opt/netgen/lib/libngstd.a -L/opt/intel/mkl/10.2.1.017/lib/em64t /opt/intel/mkl/10.2.1.017/lib/em64t/libmkl_solver_lp64.a -lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core # # dist_bin_SCRIPTS = dialog.tcl menustat.tcl ngicon.tcl ng.tcl \ ngvisual.tcl sockets.tcl drawing.tcl nghelp.tcl ngshell.tcl \ ngtesting.tcl parameters.tcl variables.tcl netgen.ocf netgen_LDFLAGS = -rdynamic -static netgen-4.9.13/ng/menustat.tcl0000644000175000001440000010137111374304335012763 00000000000000# 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 .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 } } } set ACISavailable [Ng_ACISCommand isACISavailable] if {$ACISavailable == "yes" } { lappend types {"ACIS Geometry" {.sat} } } if {[catch { set file [tk_getOpenFile -filetypes $types -initialdir $dirname -typevariable loadgeomtypevar] }]} { set file [tk_getOpenFile -filetypes $types -initialdir $dirname] } 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 -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 wm title . [concat "$progname - " $file] 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 { # global meshexportformats foreach exportformat $meshexportformats { if { [lindex $exportformat 0] == $exportfiletype } { set extension [lindex $exportformat 1] } } if { $exportfiletype == "Elmer Format"} { set file [file nativename [tk_chooseDirectory -title "Elmer Mesh Export - Select Directory"]] } elseif { $exportfiletype == "OpenFOAM 1.5+ Format"} { set file [file nativename [tk_chooseDirectory -title "OpenFOAM 1.5+ Mesh Export - Select Case Directory"]] } else { # set file [tk_getSaveFile -filetypes "{ \"$exportfiletype\" {$extension} }" ] set file [tk_getSaveFile -filetypes "{ \"$exportfiletype\" {*}}" ] } 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; } # Philippose - 30/01/2009 # Add menu item for local face mesh size definition in the # TCL Gui .ngmenu.geometry add command -label "Edit Face Mesh Size..." \ -command { surfacemeshsizedialog } .ngmenu.geometry add command -label "OCC Construction" \ -command { Ng_OCCConstruction; } 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 "Prismatic Boundary Layer" \ -command { Ng_GenerateBoundaryLayer; redraw } .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; } .ngmenu.special add cascade -label "Colour-based boundary conditions" -menu .ngmenu.special.colbndcond menu .ngmenu.special.colbndcond .ngmenu.special.colbndcond add command -label "Automatic Assignment" \ -command { Ng_AutoColourBcProps auto; redraw } .ngmenu.special.colbndcond add separator set ocffile [file join ${ngdir} netgen.ocf]; .ngmenu.special.colbndcond add command -label "Select Colour Profile file" \ -command { set types { {"Colour Profile file" {.ocf} } } set ocffile [tk_getOpenFile -filetypes $types] if {$ocffile == ""} { set ocffile [file join ${ngdir} netgen.ocf]; } } .ngmenu.special.colbndcond add command -label "Profile based Assignment" \ -command { Ng_AutoColourBcProps profile ${ocffile}; redraw } # 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 \nmainly written by \nJoachim Schoeberl \nthanks to \nRobert Gaisbauer, Johannes Gerstmayr, Philippose Rajan" } # 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 { set ans [tk_messageBox -title "Quit Netgen?" -message "Do you really want to quit Netgen?" -type yesno -default "no" -icon question] if { $ans == "yes" } { .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" } ; netgen-4.9.13/ng/ng.tcl0000644000175000001440000001335011252515022011516 00000000000000puts "Parsing ng.tcl" if {[catch {package require Tix } result ]} { puts "cannot find package Tix" puts "error : $result" } # if {[catch {package require Togl 2.0 } result ]} { # puts "cannot find package Togl 2.0" # puts "error : $result" # } # 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 nguserdir "" if { [lsearch [array names env] NETGEN_USER_DIR] != -1 } { set nguserdir $env(NETGEN_USER_DIR) } if { [string length $nguserdir] == 0 } { set nguserdir "." } 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 } 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 } catch { source ${ngdir}/ngsolve.tcl } 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 # } catch { source ${ngdir}/demoapp.tcl } netgen-4.9.13/ng/Makefile.in0000644000175000001440000005215011375342730012466 00000000000000# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ bin_PROGRAMS = netgen$(EXEEXT) subdir = ng DIST_COMMON = $(dist_bin_SCRIPTS) $(include_HEADERS) \ $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/tcl.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)" \ "$(DESTDIR)$(includedir)" binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) am_netgen_OBJECTS = demoview.$(OBJEXT) ngappinit.$(OBJEXT) \ ngpkg.$(OBJEXT) onetcl.$(OBJEXT) nginterface.$(OBJEXT) \ nginterface_v2.$(OBJEXT) parallelfunc.$(OBJEXT) \ parallelinterface.$(OBJEXT) netgen_OBJECTS = $(am_netgen_OBJECTS) am__DEPENDENCIES_1 = netgen_DEPENDENCIES = \ $(top_builddir)/libsrc/visualization/libvisual.a \ $(top_builddir)/libsrc/csg/libcsg.la \ $(top_builddir)/libsrc/geom2d/libgeom2d.la \ $(top_builddir)/libsrc/interface/libinterface.la \ $(top_builddir)/libsrc/stlgeom/libstl.la \ $(top_builddir)/libsrc/occ/libocc.la \ $(top_builddir)/libsrc/meshing/libmesh.la \ $(top_builddir)/libsrc/gprim/libgprim.la \ $(top_builddir)/libsrc/linalg/libla.la \ $(top_builddir)/libsrc/general/libgen.la $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) netgen_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \ $(netgen_LDFLAGS) $(LDFLAGS) -o $@ dist_binSCRIPT_INSTALL = $(INSTALL_SCRIPT) SCRIPTS = $(dist_bin_SCRIPTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(netgen_SOURCES) DIST_SOURCES = $(netgen_SOURCES) am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; includeHEADERS_INSTALL = $(INSTALL_HEADER) HEADERS = $(include_HEADERS) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH = @CYGPATH@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FFMPEG_INCLUDES = @FFMPEG_INCLUDES@ FFMPEG_LIBS = @FFMPEG_LIBS@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ JPEGLIB_INCLUDES = @JPEGLIB_INCLUDES@ JPEGLIB_LIBS = @JPEGLIB_LIBS@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBGLU = @LIBGLU@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MPI_INCLUDES = @MPI_INCLUDES@ MPI_LIBS = @MPI_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OCCFLAGS = @OCCFLAGS@ OCCLIBS = @OCCLIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CFLAGS = @PKG_CFLAGS@ PKG_HEADERS = @PKG_HEADERS@ PKG_INCLUDES = @PKG_INCLUDES@ PKG_LIBS = @PKG_LIBS@ PKG_LIB_FILE = @PKG_LIB_FILE@ PKG_STUB_LIB_FILE = @PKG_STUB_LIB_FILE@ PKG_STUB_OBJECTS = @PKG_STUB_OBJECTS@ PKG_STUB_SOURCES = @PKG_STUB_SOURCES@ PKG_TCL_SOURCES = @PKG_TCL_SOURCES@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ TCL_BIN_DIR = @TCL_BIN_DIR@ TCL_DEFS = @TCL_DEFS@ TCL_EXTRA_CFLAGS = @TCL_EXTRA_CFLAGS@ TCL_INCLUDES = @TCL_INCLUDES@ TCL_LD_FLAGS = @TCL_LD_FLAGS@ TCL_LIBS = @TCL_LIBS@ TCL_LIB_FILE = @TCL_LIB_FILE@ TCL_LIB_FLAG = @TCL_LIB_FLAG@ TCL_LIB_SPEC = @TCL_LIB_SPEC@ TCL_SHLIB_LD_LIBS = @TCL_SHLIB_LD_LIBS@ TCL_SRC_DIR = @TCL_SRC_DIR@ TCL_STUB_LIB_FILE = @TCL_STUB_LIB_FILE@ TCL_STUB_LIB_FLAG = @TCL_STUB_LIB_FLAG@ TCL_STUB_LIB_SPEC = @TCL_STUB_LIB_SPEC@ TCL_VERSION = @TCL_VERSION@ TK_BIN_DIR = @TK_BIN_DIR@ TK_LIBS = @TK_LIBS@ TK_LIB_FILE = @TK_LIB_FILE@ TK_LIB_FLAG = @TK_LIB_FLAG@ TK_LIB_SPEC = @TK_LIB_SPEC@ TK_SRC_DIR = @TK_SRC_DIR@ TK_STUB_LIB_FILE = @TK_STUB_LIB_FILE@ TK_STUB_LIB_FLAG = @TK_STUB_LIB_FLAG@ TK_STUB_LIB_SPEC = @TK_STUB_LIB_SPEC@ TK_VERSION = @TK_VERSION@ TK_XINCLUDES = @TK_XINCLUDES@ TOGLLIBDIR = @TOGLLIBDIR@ TOGL_WINDOWINGSYSTEM = @TOGL_WINDOWINGSYSTEM@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ include_HEADERS = AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include -I$(top_srcdir)/libsrc/interface -DOPENGL -D$(TOGL_WINDOWINGSYSTEM) $(OCCFLAGS) $(TCL_INCLUDES) $(MPI_INCLUDES) $(FFMPEG_INCLUDES) $(JPEGLIB_INCLUDES) netgen_SOURCES = demoview.cpp ngappinit.cpp ngpkg.cpp onetcl.cpp nginterface.cpp nginterface_v2.cpp parallelfunc.cpp parallelinterface.cpp demoview.hpp parallelfunc.hpp togl_1_7.h netgen_LDADD = $(top_builddir)/libsrc/visualization/libvisual.a \ $(top_builddir)/libsrc/csg/libcsg.la \ $(top_builddir)/libsrc/geom2d/libgeom2d.la \ $(top_builddir)/libsrc/interface/libinterface.la \ $(top_builddir)/libsrc/stlgeom/libstl.la \ $(top_builddir)/libsrc/occ/libocc.la \ $(top_builddir)/libsrc/meshing/libmesh.la \ $(top_builddir)/libsrc/gprim/libgprim.la \ $(top_builddir)/libsrc/linalg/libla.la \ $(top_builddir)/libsrc/general/libgen.la \ $(OCCLIBS) -L$(TK_BIN_DIR)/Togl1.7 $(TOGLLIBDIR) -lTogl1.7 $(LIBGLU) $(TK_LIB_SPEC) $(TCL_LIB_SPEC) $(MPI_LIBS) $(FFMPEG_LIBS) $(JPEGLIB_LIBS) $(PKG_LIBS) # add for static linkage of ngsolve: # /opt/netgen/lib/libngsolve.a /opt/netgen/lib/libngcomp.a /opt/netgen/lib/libngcomp.a /opt/netgen/lib/libngfemng.a /opt/netgen/lib/libngmg.a /opt/netgen/lib/libngla.a /opt/netgen/lib/libngbla.a /opt/netgen/lib/libngstd.a -L/opt/intel/mkl/10.2.1.017/lib/em64t /opt/intel/mkl/10.2.1.017/lib/em64t/libmkl_solver_lp64.a -lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core # # dist_bin_SCRIPTS = dialog.tcl menustat.tcl ngicon.tcl ng.tcl \ ngvisual.tcl sockets.tcl drawing.tcl nghelp.tcl ngshell.tcl \ ngtesting.tcl parameters.tcl variables.tcl netgen.ocf netgen_LDFLAGS = -rdynamic -static all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign ng/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --foreign ng/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; for p in $$list; do \ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ if test -f $$p \ || test -f $$p1 \ ; then \ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ else :; fi; \ done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; for p in $$list; do \ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ rm -f "$(DESTDIR)$(bindir)/$$f"; \ done clean-binPROGRAMS: @list='$(bin_PROGRAMS)'; for p in $$list; do \ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ echo " rm -f $$p $$f"; \ rm -f $$p $$f ; \ done netgen$(EXEEXT): $(netgen_OBJECTS) $(netgen_DEPENDENCIES) @rm -f netgen$(EXEEXT) $(netgen_LINK) $(netgen_OBJECTS) $(netgen_LDADD) $(LIBS) install-dist_binSCRIPTS: $(dist_bin_SCRIPTS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(dist_bin_SCRIPTS)'; for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ if test -f $$d$$p; then \ f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ echo " $(dist_binSCRIPT_INSTALL) '$$d$$p' '$(DESTDIR)$(bindir)/$$f'"; \ $(dist_binSCRIPT_INSTALL) "$$d$$p" "$(DESTDIR)$(bindir)/$$f"; \ else :; fi; \ done uninstall-dist_binSCRIPTS: @$(NORMAL_UNINSTALL) @list='$(dist_bin_SCRIPTS)'; for p in $$list; do \ f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ rm -f "$(DESTDIR)$(bindir)/$$f"; \ done mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/demoview.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ngappinit.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nginterface.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nginterface_v2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ngpkg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/onetcl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parallelfunc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parallelinterface.Po@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs install-includeHEADERS: $(include_HEADERS) @$(NORMAL_INSTALL) test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)" @list='$(include_HEADERS)'; for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ f=$(am__strip_dir) \ echo " $(includeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(includedir)/$$f'"; \ $(includeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(includedir)/$$f"; \ done uninstall-includeHEADERS: @$(NORMAL_UNINSTALL) @list='$(include_HEADERS)'; for p in $$list; do \ f=$(am__strip_dir) \ echo " rm -f '$(DESTDIR)$(includedir)/$$f'"; \ rm -f "$(DESTDIR)$(includedir)/$$f"; \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) $(SCRIPTS) $(HEADERS) installdirs: for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(includedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am info: info-am info-am: install-data-am: install-includeHEADERS install-dvi: install-dvi-am install-exec-am: install-binPROGRAMS install-dist_binSCRIPTS install-html: install-html-am install-info: install-info-am install-man: install-pdf: install-pdf-am install-ps: install-ps-am installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-dist_binSCRIPTS \ uninstall-includeHEADERS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ clean-generic clean-libtool ctags distclean distclean-compile \ distclean-generic distclean-libtool distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-binPROGRAMS install-data install-data-am \ install-dist_binSCRIPTS install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-includeHEADERS install-info install-info-am \ install-man install-pdf install-pdf-am install-ps \ install-ps-am install-strip installcheck installcheck-am \ installdirs maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ uninstall-am uninstall-binPROGRAMS uninstall-dist_binSCRIPTS \ uninstall-includeHEADERS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: netgen-4.9.13/ng/onetcl.cpp0000644000175000001440000105733111240003500012374 00000000000000const char * ngscript[] = { "\n",\ "\n",\ "if {[catch {package require Tix }]} {\n",\ " puts \"cannot find package Tix\"\n",\ "}\n",\ "set userlevel 3\n",\ "if { [Ng_GetCommandLineParameter expert]==\"defined\" } {\n",\ " set userlevel 3\n",\ "}\n",\ "\n",\ "set progname \"NETGEN\"\n",\ "\n",\ "set ngdir \"\"\n",\ "if { [lsearch [array names env] NETGENDIR] != -1 } {\n",\ " set ngdir $env(NETGENDIR) \n",\ "}\n",\ "if { [string length $ngdir] == 0 } {\n",\ " set ngdir \".\" \n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "set batchmode [Ng_GetCommandLineParameter batchmode]\n",\ "\n",\ "set solvemode 0\n",\ "if { [Ng_GetCommandLineParameter solve] != \"undefined\" || [Ng_GetCommandLineParameter recent] == \"defined\" } {\n",\ " set solvemode defined\n",\ "}\n",\ "\n",\ "set shellmode [Ng_GetCommandLineParameter shellmode]\n",\ "\n",\ "if { $shellmode == \"defined\" } {\n",\ " set batchmode \"defined\"\n",\ "}\n",\ "\n",\ "\n",\ "if { $batchmode != \"defined\" } {\n",\ " catch {\n",\ " wm withdraw .\n",\ " \n",\ " wm title . $progname\n",\ " wm geometry . =800x600\n",\ " wm minsize . 400 300\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "set drawmode rotate\n",\ "set selectvisual geometry\n",\ "\n",\ "set dirname .\n",\ "set basefilename filename\n",\ "\n",\ "set meshoptions.fineness 3\n",\ "set meshoptions.firststep ag\n",\ "set meshoptions.laststep ov\n",\ "set options.memory 0\n",\ "\n",\ "set options.localh 1\n",\ "set options.delaunay 1\n",\ "set options.checkoverlap 1\n",\ "set options.checkoverlappingboundary 0\n",\ "set options.checkchartboundary 1\n",\ "set options.startinsurface 0\n",\ "set options.blockfill 1\n",\ "set options.debugmode 0\n",\ "set options.dooptimize 1\n",\ "set options.parthread 1\n",\ "set options.elsizeweight 0.2\n",\ "set options.secondorder 0\n",\ "set options.elementorder 1\n",\ "set options.quad 0\n",\ "set options.inverttets 0\n",\ "set options.inverttrigs 0\n",\ "set options.autozrefine 0\n",\ "\n",\ "\n",\ "set options.meshsize 1000\n",\ "set options.minmeshsize 0\n",\ "\n",\ "set options.curvaturesafety 2\n",\ "set options.segmentsperedge 2\n",\ "set options.meshsizefilename \"\"\n",\ "set options.badellimit 175\n",\ "set options.optsteps2d 3\n",\ "set options.optsteps3d 5\n",\ "set options.opterrpow 2\n",\ "\n",\ "set options.grading 0.5\n",\ "set options.printmsg 2\n",\ "\n",\ "set debug.slowchecks 0\n",\ "set debug.debugoutput 0\n",\ "set debug.haltexistingline 0\n",\ "set debug.haltoverlap 0\n",\ "set debug.haltsuccess 0\n",\ "set debug.haltnosuccess 0\n",\ "set debug.haltlargequalclass 0\n",\ "set debug.haltsegment 0\n",\ "set debug.haltnode 0\n",\ "set debug.haltface 0\n",\ "set debug.haltfacenr 0\n",\ "set debug.haltsegmentp1 0\n",\ "set debug.haltsegmentp2 0\n",\ "\n",\ "set geooptions.drawcsg 1\n",\ "set geooptions.detail 0.001\n",\ "set geooptions.accuracy 1e-6\n",\ "set geooptions.facets 20\n",\ "set geooptions.minx -1000\n",\ "set geooptions.miny -1000\n",\ "set geooptions.minz -1000\n",\ "set geooptions.maxx 1000\n",\ "set geooptions.maxy 1000\n",\ "set geooptions.maxz 1000\n",\ "\n",\ "set viewqualityplot 0\n",\ "set memuseplot 0\n",\ "set viewrotatebutton 0\n",\ "set showsensitivehelp 0\n",\ "set showhelpline 0\n",\ "\n",\ "set viewoptions.specpointvlen 0.3\n",\ "set viewoptions.light.amb 0.3\n",\ "set viewoptions.light.diff 0.7\n",\ "set viewoptions.light.spec 1\n",\ "set viewoptions.light.locviewer 0\n",\ "set viewoptions.mat.shininess 50\n",\ "set viewoptions.mat.transp 0.3\n",\ "set viewoptions.colormeshsize 0\n",\ "set viewoptions.whitebackground 1\n",\ "set viewoptions.drawcoordinatecross 1\n",\ "set viewoptions.drawcolorbar 1\n",\ "set viewoptions.drawnetgenlogo 1\n",\ "set viewoptions.stereo 0\n",\ "set viewoptions.shrink 1\n",\ "\n",\ "set viewoptions.drawfilledtrigs 1\n",\ "set viewoptions.drawedges 0\n",\ "set viewoptions.drawbadels 0\n",\ "set viewoptions.centerpoint 0\n",\ "set viewoptions.drawelement 0\n",\ "set viewoptions.drawoutline 1\n",\ "set viewoptions.drawtets 0\n",\ "set viewoptions.drawtetsdomain 0\n",\ "set viewoptions.drawprisms 0\n",\ "set viewoptions.drawpyramids 0\n",\ "set viewoptions.drawhexes 0\n",\ "set viewoptions.drawidentified 0\n",\ "set viewoptions.drawpointnumbers 0\n",\ "set viewoptions.drawedgenumbers 0\n",\ "set viewoptions.drawfacenumbers 0\n",\ "set viewoptions.drawelementnumbers 0\n",\ "set viewoptions.drawdomainsurf 0\n",\ "\n",\ "set viewoptions.drawededges 1\n",\ "set viewoptions.drawedpoints 1\n",\ "set viewoptions.drawedpointnrs 0\n",\ "set viewoptions.drawedtangents 0\n",\ "set viewoptions.drawededgenrs 0\n",\ "set viewoptions.drawmetispartition 0\n",\ "\n",\ "set viewoptions.drawcurveproj 0\n",\ "set viewoptions.drawcurveprojedge 1\n",\ "\n",\ "set viewoptions.clipping.nx 0\n",\ "set viewoptions.clipping.ny 1\n",\ "set viewoptions.clipping.nz 0\n",\ "set viewoptions.clipping.dist 0\n",\ "set viewoptions.clipping.enable 0\n",\ "set viewoptions.clipping.onlydomain 0\n",\ "set viewoptions.clipping.notdomain 0\n",\ "\n",\ "set viewoptions.usecentercoords 0\n",\ "set viewoptions.centerx 0\n",\ "set viewoptions.centery 0\n",\ "set viewoptions.centerz 0\n",\ "\n",\ "set viewoptions.drawspecpoint 0\n",\ "set viewoptions.specpointx 0\n",\ "set viewoptions.specpointy 0\n",\ "set viewoptions.specpointz 0\n",\ "\n",\ "\n",\ "set stloptions.showtrias 0\n",\ "set stloptions.showfilledtrias 1\n",\ "set stloptions.showedges 1\n",\ "set stloptions.showmarktrias 0\n",\ "set stloptions.showactivechart 0\n",\ "set stloptions.yangle 30\n",\ "set stloptions.contyangle 20\n",\ "set stloptions.edgecornerangle 60\n",\ "set stloptions.chartangle 15\n",\ "set stloptions.outerchartangle 70\n",\ "set stloptions.usesearchtree 0\n",\ "set stloptions.chartnumber 1\n",\ "set stloptions.charttrignumber 1\n",\ "set stloptions.chartnumberoffset 0\n",\ "\n",\ "set stloptions.atlasminh 0.1\n",\ "set stloptions.resthsurfcurvfac 2\n",\ "set stloptions.resthsurfcurvenable 0\n",\ "set stloptions.resthatlasfac 2\n",\ "set stloptions.resthatlasenable 1\n",\ "set stloptions.resthchartdistfac 1.2\n",\ "set stloptions.resthchartdistenable 1\n",\ "set stloptions.resthlinelengthfac 0.5\n",\ "set stloptions.resthlinelengthenable 1\n",\ "set stloptions.resthcloseedgefac 1\n",\ "set stloptions.resthcloseedgeenable 1\n",\ "set stloptions.resthedgeanglefac 1\n",\ "set stloptions.resthedgeangleenable 0\n",\ "set stloptions.resthsurfmeshcurvfac 1\n",\ "set stloptions.resthsurfmeshcurvenable 0\n",\ "set stloptions.recalchopt 1\n",\ "\n",\ "set stldoctor.drawmeshededges 1\n",\ "set stldoctor.geom_tol_fact 0.000001\n",\ "set stldoctor.useexternaledges 0\n",\ "set stldoctor.showfaces 0\n",\ "set stldoctor.conecheck 1\n",\ "set stldoctor.spiralcheck 1\n",\ "set stldoctor.selecttrig 0\n",\ "set stldoctor.selectmode 1\n",\ "set stldoctor.longlinefact 0\n",\ "set stldoctor.showexcluded 1\n",\ "set stldoctor.edgeselectmode 0\n",\ "set stldoctor.nodeofseltrig 1\n",\ "set stldoctor.showtouchedtrigchart 0\n",\ "set stldoctor.showedgecornerpoints 0\n",\ "set stldoctor.showmarkedtrigs 1\n",\ "set stldoctor.dirtytrigfact 0.01\n",\ "set stldoctor.smoothangle 90\n",\ "set stldoctor.selectwithmouse 1\n",\ "set stldoctor.showvicinity 0\n",\ "set stldoctor.vicinity 50\n",\ "set stldoctor.smoothnormalsweight 0.2\n",\ "\n",\ "set occoptions.showvolumenr 0\n",\ "set occoptions.showsurfaces 1\n",\ "set occoptions.showedges 1\n",\ "set occoptions.showsolidnr 0\n",\ "set occoptions.showsolidnr2 0\n",\ "set occoptions.visproblemfaces 0\n",\ "set occoptions.zoomtohighlightedentity 0\n",\ "set occoptions.deflection 1\n",\ "set occoptions.tolerance 1e-3\n",\ "set occoptions.fixsmalledges 1\n",\ "set occoptions.fixspotstripfaces 1\n",\ "set occoptions.sewfaces 1\n",\ "set occoptions.makesolids 1\n",\ "set occoptions.splitpartitions 0\n",\ "\n",\ "set meshdoctor.active 0\n",\ "set meshdoctor.markedgedist 1\n",\ "\n",\ "\n",\ "set status_np 0\n",\ "set status_ne 0\n",\ "set status_nse 0\n",\ "set status_working \" \"\n",\ "set status_task \" \"\n",\ "set status_percent 0\n",\ "set status_filename 0\n",\ "set status_tetqualclasses \"10 20 30 40 10 20 30 40 10 20 30 40 10 20 30 40 10 20 30 40\"\n",\ "\n",\ "set exportfiletype PERMAS\n",\ "\n",\ "set preproc.facenr 0\n",\ "set preproc.selectmode query\n",\ "set preproc.numtrig 0\n",\ "\n",\ "set mem_moveable 0\n",\ "\n",\ "\n",\ "set multithread_pause 0\n",\ "set multithread_testmode 0\n",\ "set multithread_redraw 0\n",\ "set multithread_drawing 0\n",\ "set multithread_terminate 0\n",\ "set multithread_running 0\n",\ "\n",\ "set level 0\n",\ "\n",\ "\n",\ "set tablesforoutput {}\n",\ "\n",\ "\n",\ "\n",\ "set optlist {\n",\ " options.localh \n",\ " options.delaunay \n",\ " options.checkoverlap \n",\ " options.startinsurface \n",\ " options.blockfill \n",\ " options.dooptimize \n",\ " options.elsizeweight \n",\ " options.meshsize \n",\ " options.minmeshsize \n",\ " options.curvaturesafety \n",\ " options.optsteps2d \n",\ " options.optsteps3d \n",\ " options.secondorder\n",\ "}\n",\ "\n",\ "\n",\ "set visoptions.usetexture 0\n",\ "set visoptions.invcolor 0\n",\ "set visoptions.imaginary 0\n",\ "set visoptions.lineartexture 1\n",\ "set visoptions.numtexturecols 16\n",\ "set visoptions.showclipsolution 1\n",\ "set visoptions.showsurfacesolution 0\n",\ "set visoptions.drawfieldlines 0\n",\ "set visoptions.drawpointcurves 1\n",\ "set visoptions.numfieldlines 100\n",\ "set visoptions.fieldlinesrandomstart 0\n",\ "set visoptions.fieldlinesstartarea box\n",\ "set visoptions.fieldlinesstartareap1x 1\n",\ "set visoptions.fieldlinesstartareap1y 1\n",\ "set visoptions.fieldlinesstartareap1z 1\n",\ "set visoptions.fieldlinesstartareap2x 0\n",\ "set visoptions.fieldlinesstartareap2y 0\n",\ "set visoptions.fieldlinesstartareap2z 0\n",\ "set visoptions.fieldlinesstartface -1\n",\ "set visoptions.fieldlinesfilename none\n",\ "set visoptions.fieldlinestolerance 0.0005\n",\ "set visoptions.fieldlinesrktype crungekutta\n",\ "set visoptions.fieldlineslength 0.5\n",\ "set visoptions.fieldlinesmaxpoints 500\n",\ "set visoptions.fieldlinesthickness 0.0015\n",\ "set visoptions.fieldlinesvecfunction none\n",\ "set visoptions.fieldlinesphase 0\n",\ "set visoptions.fieldlinesonlyonephase 1\n",\ "\n",\ "\n",\ "set visoptions.lineplotfile empty\n",\ "set visoptions.lineplotsource file\n",\ "set visoptions.lineplotusingx 0\n",\ "set visoptions.lineplotusingy 1\n",\ "set visoptions.lineplotautoscale 1\n",\ "set visoptions.lineplotxmin 0\n",\ "set visoptions.lineplotxmax 1\n",\ "set visoptions.lineplotymin 0\n",\ "set visoptions.lineplotymax 1\n",\ "set visoptions.lineplotcurrentnum -1\n",\ "set visoptions.lineplotinfos \"\"\n",\ "set visoptions.lineplotselected none\n",\ "set visoptions.lineplotselector \"\"\n",\ "set visoptions.lineplotcolor red\n",\ "set visoptions.lineplotsizex 500\n",\ "set visoptions.lineplotsizey 400\n",\ "set visoptions.lineplotselectedeval 0\n",\ "set visoptions.lineplotdatadescr \"column1 column2 column3\"\n",\ "set visoptions.lineplotxcoordselector \"\"\n",\ "set visoptions.lineplotycoordselector \"\"\n",\ "set visoptions.evaluatefilenames none\n",\ "set visoptions.evaluatefiledescriptions none\n",\ "\n",\ "\n",\ "set visoptions.clipsolution none\n",\ "set visoptions.scalfunction none\n",\ "set visoptions.vecfunction none\n",\ "set visoptions.evaluate abs\n",\ "set visoptions.gridsize 20\n",\ "set visoptions.xoffset 0\n",\ "set visoptions.yoffset 0\n",\ "set visoptions.autoscale 1\n",\ "set visoptions.lineartexture 1\n",\ "set visoptions.redrawperiodic 0\n",\ "set visoptions.logscale 0\n",\ "set visoptions.mminval 0\n",\ "set visoptions.mmaxval 1\n",\ "set visoptions.isolines 0\n",\ "set visoptions.isosurf 0\n",\ "set visoptions.subdivisions 1\n",\ "set visoptions.numiso 10\n",\ "set visoptions.autoredraw 0\n",\ "set visoptions.autoredrawtime 2\n",\ "set visoptions.simulationtime 0\n",\ "set visoptions.multidimcomponent 0\n",\ "\n",\ "set visoptions.deformation 0\n",\ "set visoptions.scaledeform1 1\n",\ "set visoptions.scaledeform2 1\n",\ "\n",\ "set parallel_netgen 0\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "set optfilename ng.opt\n",\ "global env\n",\ "if { [llength [array names env NG_OPT]] == 1 } {\n",\ " if { [string length $env(NG_OPT)] > 0 } {\n",\ " set optfilename $env(NG_OPT) \n",\ " }\n",\ "}\n",\ "\n",\ "if { [file exists $optfilename] == 1 } {\n",\ " set datei [open $optfilename r]\n",\ " while { [gets $datei line] >= 0 } {\n",\ " set [lindex $line 0] [lindex $line 1]\n",\ " }\n",\ " close $datei\n",\ "} {\n",\ " puts \"optfile $optfilename does not exist - using default values\"\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "proc saveoptions { } {\n",\ " uplevel 1 {\n",\ " set file ng.opt \n",\ " \n",\ " if {$file != \"\"} {\n",\ " set datei [open $file w]\n",\ " \n",\ " puts $datei \"meshoptions.fineness ${meshoptions.fineness}\"\n",\ " puts $datei \"meshoptions.firststep ${meshoptions.firststep}\"\n",\ " puts $datei \"meshoptions.laststep ${meshoptions.laststep}\" \n",\ " puts $datei \"options.localh ${options.localh}\"\n",\ " puts $datei \"options.delaunay ${options.delaunay}\"\n",\ " puts $datei \"options.checkoverlap ${options.checkoverlap}\"\n",\ " puts $datei \"options.checkchartboundary ${options.checkchartboundary}\"\n",\ " puts $datei \"options.startinsurface ${options.startinsurface}\" \n",\ " puts $datei \"options.blockfill ${options.blockfill}\" \n",\ " puts $datei \"options.debugmode ${options.debugmode}\" \n",\ " puts $datei \"options.dooptimize ${options.dooptimize}\" \n",\ " puts $datei \"options.parthread ${options.parthread}\" \n",\ " puts $datei \"options.elsizeweight ${options.elsizeweight}\" \n",\ " puts $datei \"options.secondorder ${options.secondorder}\" \n",\ " puts $datei \"options.elementorder ${options.elementorder}\" \n",\ " puts $datei \"options.memory ${options.memory}\" \n",\ " puts $datei \"options.quad ${options.quad}\" \n",\ " puts $datei \"options.inverttets ${options.inverttets}\" \n",\ " puts $datei \"options.inverttrigs ${options.inverttrigs}\" \n",\ " puts $datei \"options.autozrefine ${options.autozrefine}\" \n",\ " puts $datei \"options.meshsize ${options.meshsize}\" \n",\ " puts $datei \"options.minmeshsize ${options.minmeshsize}\" \n",\ " puts $datei \"options.curvaturesafety ${options.curvaturesafety}\" \n",\ " puts $datei \"options.segmentsperedge ${options.segmentsperedge}\" \n",\ " puts $datei \"options.meshsizefilename ${options.meshsizefilename}\" \n",\ " puts $datei \"options.badellimit ${options.badellimit}\" \n",\ " puts $datei \"options.optsteps2d ${options.optsteps2d}\" \n",\ " puts $datei \"options.optsteps3d ${options.optsteps3d}\" \n",\ " puts $datei \"options.opterrpow ${options.opterrpow}\" \n",\ " puts $datei \"options.grading ${options.grading}\" \n",\ " puts $datei \"options.printmsg ${options.printmsg}\" \n",\ " puts $datei \"geooptions.drawcsg ${geooptions.drawcsg}\" \n",\ " puts $datei \"geooptions.detail ${geooptions.detail}\" \n",\ " puts $datei \"geooptions.accuracy ${geooptions.accuracy}\" \n",\ " puts $datei \"geooptions.facets ${geooptions.facets}\" \n",\ " puts $datei \"geooptions.minx ${geooptions.minx}\" \n",\ " puts $datei \"geooptions.miny ${geooptions.miny}\" \n",\ " puts $datei \"geooptions.minz ${geooptions.minz}\" \n",\ " puts $datei \"geooptions.maxx ${geooptions.maxx}\" \n",\ " puts $datei \"geooptions.maxy ${geooptions.maxy}\" \n",\ " puts $datei \"geooptions.maxz ${geooptions.maxz}\" \n",\ " puts $datei \"viewoptions.specpointvlen ${viewoptions.specpointvlen}\" \n",\ " puts $datei \"viewoptions.light.amb ${viewoptions.light.amb}\" \n",\ " puts $datei \"viewoptions.light.diff ${viewoptions.light.diff}\"\n",\ " puts $datei \"viewoptions.light.spec ${viewoptions.light.spec}\"\n",\ " puts $datei \"viewoptions.light.locviewer ${viewoptions.light.locviewer}\"\n",\ " puts $datei \"viewoptions.mat.shininess ${viewoptions.mat.shininess}\" \n",\ " puts $datei \"viewoptions.mat.transp ${viewoptions.mat.transp}\" \n",\ " puts $datei \"viewoptions.colormeshsize ${viewoptions.colormeshsize}\"\n",\ " puts $datei \"viewoptions.whitebackground ${viewoptions.whitebackground}\" \n",\ " puts $datei \"viewoptions.drawcolorbar ${viewoptions.drawcolorbar}\" \n",\ " puts $datei \"viewoptions.drawcoordinatecross ${viewoptions.drawcoordinatecross}\" \n",\ " puts $datei \"viewoptions.drawnetgenlogo ${viewoptions.drawnetgenlogo}\" \n",\ " puts $datei \"viewoptions.stereo ${viewoptions.stereo}\" \n",\ " puts $datei \"viewoptions.drawfilledtrigs ${viewoptions.drawfilledtrigs}\" \n",\ " puts $datei \"viewoptions.drawedges ${viewoptions.drawedges}\" \n",\ " puts $datei \"viewoptions.drawbadels ${viewoptions.drawbadels}\" \n",\ " puts $datei \"viewoptions.centerpoint ${viewoptions.centerpoint}\" \n",\ " puts $datei \"viewoptions.drawelement ${viewoptions.drawelement}\" \n",\ " puts $datei \"viewoptions.drawoutline ${viewoptions.drawoutline}\" \n",\ " puts $datei \"viewoptions.drawtets ${viewoptions.drawtets}\"\n",\ " puts $datei \"viewoptions.drawprisms ${viewoptions.drawprisms}\"\n",\ " puts $datei \"viewoptions.drawpyramids ${viewoptions.drawpyramids}\" \n",\ " puts $datei \"viewoptions.drawhexes ${viewoptions.drawhexes}\" \n",\ " puts $datei \"viewoptions.drawidentified ${viewoptions.drawidentified}\" \n",\ " puts $datei \"viewoptions.drawpointnumbers ${viewoptions.drawpointnumbers}\" \n",\ " \n",\ " puts $datei \"viewoptions.drawededges ${viewoptions.drawededges}\" \n",\ " puts $datei \"viewoptions.drawedpoints ${viewoptions.drawedpoints}\" \n",\ " puts $datei \"viewoptions.drawedpointnrs ${viewoptions.drawedpointnrs}\" \n",\ " puts $datei \"viewoptions.drawedtangents ${viewoptions.drawedtangents}\" \n",\ " puts $datei \"viewoptions.shrink ${viewoptions.shrink}\" \n",\ " \n",\ " puts $datei \"stloptions.showtrias ${stloptions.showtrias}\" \n",\ " puts $datei \"stloptions.showfilledtrias ${stloptions.showfilledtrias}\" \n",\ " puts $datei \"stloptions.showedges ${stloptions.showedges}\" \n",\ " puts $datei \"stloptions.showmarktrias ${stloptions.showmarktrias}\" \n",\ " puts $datei \"stloptions.showactivechart ${stloptions.showactivechart}\" \n",\ " puts $datei \"stloptions.yangle ${stloptions.yangle}\" \n",\ " puts $datei \"stloptions.contyangle ${stloptions.contyangle}\" \n",\ " puts $datei \"stloptions.edgecornerangle ${stloptions.edgecornerangle}\" \n",\ " puts $datei \"stloptions.chartangle ${stloptions.chartangle}\" \n",\ " puts $datei \"stloptions.outerchartangle ${stloptions.outerchartangle}\" \n",\ " puts $datei \"stloptions.usesearchtree ${stloptions.usesearchtree}\" \n",\ " puts $datei \"stloptions.chartnumber ${stloptions.chartnumber}\" \n",\ " puts $datei \"stloptions.charttrignumber ${stloptions.charttrignumber}\" \n",\ " puts $datei \"stloptions.chartnumberoffset ${stloptions.chartnumberoffset}\" \n",\ " puts $datei \"stloptions.atlasminh ${stloptions.atlasminh}\" \n",\ " puts $datei \"stloptions.resthsurfcurvfac ${stloptions.resthsurfcurvfac}\" \n",\ " puts $datei \"stloptions.resthsurfcurvenable ${stloptions.resthsurfcurvenable}\" \n",\ " puts $datei \"stloptions.resthatlasfac ${stloptions.resthatlasfac}\" \n",\ " puts $datei \"stloptions.resthatlasenable ${stloptions.resthatlasenable}\" \n",\ " puts $datei \"stloptions.resthchartdistfac ${stloptions.resthchartdistfac}\" \n",\ " puts $datei \"stloptions.resthchartdistenable ${stloptions.resthchartdistenable}\" \n",\ " puts $datei \"stloptions.resthlinelengthfac ${stloptions.resthlinelengthfac}\" \n",\ " puts $datei \"stloptions.resthlinelengthenable ${stloptions.resthlinelengthenable}\" \n",\ " puts $datei \"stloptions.resthcloseedgefac ${stloptions.resthcloseedgefac}\" \n",\ " puts $datei \"stloptions.resthcloseedgeenable ${stloptions.resthcloseedgeenable}\" \n",\ " puts $datei \"stloptions.resthedgeanglefac ${stloptions.resthedgeanglefac}\" \n",\ " puts $datei \"stloptions.resthedgeangleenable ${stloptions.resthedgeangleenable}\" \n",\ " puts $datei \"stloptions.resthsurfmeshcurvfac ${stloptions.resthsurfmeshcurvfac}\" \n",\ " puts $datei \"stloptions.resthsurfmeshcurvenable ${stloptions.resthsurfmeshcurvenable}\" \n",\ " puts $datei \"stloptions.recalchopt ${stloptions.recalchopt}\" \n",\ " \n",\ " puts $datei \"visoptions.subdivisions ${visoptions.subdivisions}\"\n",\ "\n",\ "\n",\ " if { [info exists trafooptions.solver] == 1 } {\n",\ " puts $datei \"trafooptions.solver ${trafooptions.solver}\" \n",\ " puts $datei \"trafooptions.levels ${trafooptions.levels}\" \n",\ " puts $datei \"trafooptions.linits ${trafooptions.linits}\" \n",\ " puts $datei \"trafooptions.nonlinits ${trafooptions.nonlinits}\" \n",\ " puts $datei \"trafooptions.stabcurrent ${trafooptions.stabcurrent}\" \n",\ " puts $datei \"trafooptions.checkcond ${trafooptions.checkcond}\" \n",\ " puts $datei \"trafooptions.maxdirect ${trafooptions.maxdirect}\" \n",\ " puts $datei \"trafooptions.secondorder ${trafooptions.secondorder}\" \n",\ " puts $datei \"trafooptions.homogenizedcore ${trafooptions.homogenizedcore}\" \n",\ " puts $datei \"trafooptions.ordercore ${trafooptions.ordercore}\" \n",\ " puts $datei \"trafooptions.simplecurrents ${trafooptions.simplecurrents}\" \n",\ " puts $datei \"trafooptions.assemblecomplexmatrix ${trafooptions.assemblecomplexmatrix}\" \n",\ "\n",\ " puts $datei \"trafooptions.meshcasing ${trafooptions.meshcasing}\" \n",\ " puts $datei \"trafooptions.meshcore ${trafooptions.meshcore}\" \n",\ " puts $datei \"trafooptions.meshclumps ${trafooptions.meshclumps}\" \n",\ " puts $datei \"trafooptions.meshshields ${trafooptions.meshshields}\" \n",\ " puts $datei \"trafooptions.meshcoils ${trafooptions.meshcoils}\" \n",\ " puts $datei \"trafooptions.bcmdirectory ${trafooptions.bcmdirectory}\" \n",\ " puts $datei \"trafooptions.lossdensityfile ${trafooptions.lossdensityfile}\" \n",\ " }\n",\ "\n",\ " if { [info exists smalltrafomodell.tankheight] == 1 } {\n",\ " puts $datei \"smalltrafomodell.tankheight ${smalltrafomodell.tankheight}\"\n",\ " puts $datei \"smalltrafomodell.tankwidth ${smalltrafomodell.tankwidth}\"\n",\ " puts $datei \"smalltrafomodell.tanklength ${smalltrafomodell.tanklength}\"\n",\ " puts $datei \"smalltrafomodell.corewidth ${smalltrafomodell.corewidth}\"\n",\ " puts $datei \"smalltrafomodell.windowheight ${smalltrafomodell.windowheight}\"\n",\ " puts $datei \"smalltrafomodell.limbdistance ${smalltrafomodell.limbdistance}\"\n",\ " puts $datei \"smalltrafomodell.xposcore ${smalltrafomodell.xposcore}\"\n",\ " puts $datei \"smalltrafomodell.yposcore ${smalltrafomodell.yposcore}\"\n",\ " puts $datei \"smalltrafomodell.zposcore ${smalltrafomodell.zposcore}\"\n",\ " puts $datei \"smalltrafomodell.leakagefluxguidethickness ${smalltrafomodell.leakagefluxguidethickness}\"\n",\ " puts $datei \"smalltrafomodell.leakagefluxguidewidth ${smalltrafomodell.leakagefluxguidewidth}\"\n",\ " puts $datei \"smalltrafomodell.leakagefluxguidezposition ${smalltrafomodell.leakagefluxguidezposition}\"\n",\ " puts $datei \"smalltrafomodell.limbcoil.1 ${smalltrafomodell.limbcoil.1}\"\n",\ " puts $datei \"smalltrafomodell.ricoil.1 ${smalltrafomodell.ricoil.1}\"\n",\ " puts $datei \"smalltrafomodell.rocoil.1 ${smalltrafomodell.rocoil.1}\"\n",\ " puts $datei \"smalltrafomodell.zposcoil.1 ${smalltrafomodell.zposcoil.1}\"\n",\ " puts $datei \"smalltrafomodell.heightcoil.1 ${smalltrafomodell.heightcoil.1}\"\n",\ " puts $datei \"smalltrafomodell.currentcoil.1 ${smalltrafomodell.currentcoil.1}\"\n",\ " puts $datei \"smalltrafomodell.nturnscoil.1 ${smalltrafomodell.nturnscoil.1}\"\n",\ " puts $datei \"smalltrafomodell.limbcoil.2 ${smalltrafomodell.limbcoil.2}\"\n",\ " puts $datei \"smalltrafomodell.ricoil.2 ${smalltrafomodell.ricoil.2}\"\n",\ " puts $datei \"smalltrafomodell.rocoil.2 ${smalltrafomodell.rocoil.2}\"\n",\ " puts $datei \"smalltrafomodell.zposcoil.2 ${smalltrafomodell.zposcoil.2}\"\n",\ " puts $datei \"smalltrafomodell.heightcoil.2 ${smalltrafomodell.heightcoil.2}\"\n",\ " puts $datei \"smalltrafomodell.currentcoil.2 ${smalltrafomodell.currentcoil.2}\"\n",\ " puts $datei \"smalltrafomodell.nturnscoil.2 ${smalltrafomodell.nturnscoil.2}\"\n",\ " puts $datei \"smalltrafomodell.limbcoil.3 ${smalltrafomodell.limbcoil.3}\"\n",\ " puts $datei \"smalltrafomodell.ricoil.3 ${smalltrafomodell.ricoil.3}\"\n",\ " puts $datei \"smalltrafomodell.rocoil.3 ${smalltrafomodell.rocoil.3}\"\n",\ " puts $datei \"smalltrafomodell.zposcoil.3 ${smalltrafomodell.zposcoil.3}\"\n",\ " puts $datei \"smalltrafomodell.heightcoil.3 ${smalltrafomodell.heightcoil.3}\"\n",\ " puts $datei \"smalltrafomodell.currentcoil.3 ${smalltrafomodell.currentcoil.3}\"\n",\ " puts $datei \"smalltrafomodell.nturnscoil.3 ${smalltrafomodell.nturnscoil.3}\"\n",\ " puts $datei \"smalltrafomodell.limbcoil.4 ${smalltrafomodell.limbcoil.4}\"\n",\ " puts $datei \"smalltrafomodell.ricoil.4 ${smalltrafomodell.ricoil.4}\"\n",\ " puts $datei \"smalltrafomodell.rocoil.4 ${smalltrafomodell.rocoil.4}\"\n",\ " puts $datei \"smalltrafomodell.zposcoil.4 ${smalltrafomodell.zposcoil.4}\"\n",\ " puts $datei \"smalltrafomodell.heightcoil.4 ${smalltrafomodell.heightcoil.4}\"\n",\ " puts $datei \"smalltrafomodell.currentcoil.4 ${smalltrafomodell.currentcoil.4}\"\n",\ " puts $datei \"smalltrafomodell.nturnscoil.4 ${smalltrafomodell.nturnscoil.4}\"\n",\ " puts $datei \"smalltrafomodell.limbcoil.5 ${smalltrafomodell.limbcoil.5}\"\n",\ " puts $datei \"smalltrafomodell.ricoil.5 ${smalltrafomodell.ricoil.5}\"\n",\ " puts $datei \"smalltrafomodell.rocoil.5 ${smalltrafomodell.rocoil.5}\"\n",\ " puts $datei \"smalltrafomodell.zposcoil.5 ${smalltrafomodell.zposcoil.5}\"\n",\ " puts $datei \"smalltrafomodell.heightcoil.5 ${smalltrafomodell.heightcoil.5}\"\n",\ " puts $datei \"smalltrafomodell.currentcoil.5 ${smalltrafomodell.currentcoil.5}\"\n",\ " puts $datei \"smalltrafomodell.nturnscoil.5 ${smalltrafomodell.nturnscoil.5}\"\n",\ " puts $datei \"smalltrafomodell.limbcoil.6 ${smalltrafomodell.limbcoil.6}\"\n",\ " puts $datei \"smalltrafomodell.ricoil.6 ${smalltrafomodell.ricoil.6}\"\n",\ " puts $datei \"smalltrafomodell.rocoil.6 ${smalltrafomodell.rocoil.6}\"\n",\ " puts $datei \"smalltrafomodell.zposcoil.6 ${smalltrafomodell.zposcoil.6}\"\n",\ " puts $datei \"smalltrafomodell.heightcoil.6 ${smalltrafomodell.heightcoil.6}\"\n",\ " puts $datei \"smalltrafomodell.currentcoil.6 ${smalltrafomodell.currentcoil.6}\"\n",\ " puts $datei \"smalltrafomodell.nturnscoil.6 ${smalltrafomodell.nturnscoil.6}\"\n",\ " puts $datei \"smalltrafomodell.limbtest.1 ${smalltrafomodell.limbtest.1}\"\n",\ " puts $datei \"smalltrafomodell.heighttest.1 ${smalltrafomodell.heighttest.1}\"\n",\ " puts $datei \"smalltrafomodell.widthtest.1 ${smalltrafomodell.widthtest.1}\"\n",\ " puts $datei \"smalltrafomodell.rtest.1 ${smalltrafomodell.rtest.1}\"\n",\ " puts $datei \"smalltrafomodell.zpostest.1 ${smalltrafomodell.zpostest.1}\"\n",\ " puts $datei \"smalltrafomodell.edgeradiustest.1 ${smalltrafomodell.edgeradiustest.1}\"\n",\ " puts $datei \"smalltrafomodell.finetest.1 ${smalltrafomodell.finetest.1}\"\n",\ " puts $datei \"smalltrafomodell.conductivetest.1 ${smalltrafomodell.conductivetest.1}\"\n",\ " puts $datei \"smalltrafomodell.limbtest.2 ${smalltrafomodell.limbtest.2}\"\n",\ " puts $datei \"smalltrafomodell.heighttest.2 ${smalltrafomodell.heighttest.2}\"\n",\ " puts $datei \"smalltrafomodell.widthtest.2 ${smalltrafomodell.widthtest.2}\"\n",\ " puts $datei \"smalltrafomodell.rtest.2 ${smalltrafomodell.rtest.2}\"\n",\ " puts $datei \"smalltrafomodell.zpostest.2 ${smalltrafomodell.zpostest.2}\"\n",\ " puts $datei \"smalltrafomodell.edgeradiustest.2 ${smalltrafomodell.edgeradiustest.2}\"\n",\ " puts $datei \"smalltrafomodell.finetest.2 ${smalltrafomodell.finetest.2}\"\n",\ " puts $datei \"smalltrafomodell.conductivetest.2 ${smalltrafomodell.conductivetest.2}\"\n",\ " puts $datei \"smalltrafomodell.limbtest.3 ${smalltrafomodell.limbtest.3}\"\n",\ " puts $datei \"smalltrafomodell.heighttest.3 ${smalltrafomodell.heighttest.3}\"\n",\ " puts $datei \"smalltrafomodell.widthtest.3 ${smalltrafomodell.widthtest.3}\"\n",\ " puts $datei \"smalltrafomodell.rtest.3 ${smalltrafomodell.rtest.3}\"\n",\ " puts $datei \"smalltrafomodell.zpostest.3 ${smalltrafomodell.zpostest.3}\"\n",\ " puts $datei \"smalltrafomodell.edgeradiustest.3 ${smalltrafomodell.edgeradiustest.3}\"\n",\ " puts $datei \"smalltrafomodell.finetest.3 ${smalltrafomodell.finetest.3}\"\n",\ " puts $datei \"smalltrafomodell.conductivetest.3 ${smalltrafomodell.conductivetest.3}\"\n",\ " puts $datei \"smalltrafomodell.limbtest.4 ${smalltrafomodell.limbtest.4}\"\n",\ " puts $datei \"smalltrafomodell.heighttest.4 ${smalltrafomodell.heighttest.4}\"\n",\ " puts $datei \"smalltrafomodell.widthtest.4 ${smalltrafomodell.widthtest.4}\"\n",\ " puts $datei \"smalltrafomodell.rtest.4 ${smalltrafomodell.rtest.4}\"\n",\ " puts $datei \"smalltrafomodell.zpostest.4 ${smalltrafomodell.zpostest.4}\"\n",\ " puts $datei \"smalltrafomodell.edgeradiustest.4 ${smalltrafomodell.edgeradiustest.4}\"\n",\ " puts $datei \"smalltrafomodell.finetest.4 ${smalltrafomodell.finetest.4}\"\n",\ " puts $datei \"smalltrafomodell.conductivetest.4 ${smalltrafomodell.conductivetest.4}\"\n",\ " puts $datei \"smalltrafomodell.nperitest ${smalltrafomodell.nperitest}\"\n",\ " puts $datei \"smalltrafomodell.filename ${smalltrafomodell.filename}\"\n",\ " puts $datei \"smalltrafomodell.murlfguide ${smalltrafomodell.murlfguide}\"\n",\ " puts $datei \"smalltrafomodell.murtestwire ${smalltrafomodell.murtestwire}\"\n",\ " puts $datei \"smalltrafomodell.murcore ${smalltrafomodell.murcore}\"\n",\ " puts $datei \"smalltrafomodell.kappalfguide ${smalltrafomodell.kappalfguide}\"\n",\ " puts $datei \"smalltrafomodell.kappatestwire ${smalltrafomodell.kappatestwire}\"\n",\ " puts $datei \"smalltrafomodell.kappacore ${smalltrafomodell.kappacore}\"\n",\ " }\n",\ " \n",\ " \n",\ " close $datei\n",\ " }\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "proc saveinifile { } {\n",\ " uplevel 1 {\n",\ " set datei [open ng.ini w]\n",\ " for { set i [.ngmenu.file.recent index last] } { $i >= 1 } { incr i -1 } {\n",\ " puts $datei \"recentfile \\\"[.ngmenu.file.recent entrycget $i -label]\\\"\"\n",\ " }\n",\ " \n",\ " close $datei\n",\ " } \n",\ "\n",\ "\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "proc savemeshinifile { } {\n",\ " uplevel 1 {\n",\ " set datei [open ngmesh.ini w]\n",\ " for { set i [.ngmenu.file.recentmesh index last] } { $i >= 1 } { incr i -1 } {\n",\ " puts $datei \"recentfile \\\"[.ngmenu.file.recentmesh entrycget $i -label]\\\"\"\n",\ " }\n",\ " \n",\ " close $datei\n",\ " } \n",\ "\n",\ "\n",\ "}\n",\ "\n",\ "proc loadinifile { } {\n",\ " if { [file exists ng.ini] == 1 } {\n",\ " set datei [open ng.ini r]\n",\ " while { [gets $datei line] >= 0 } {\n",\ " if {[lindex $line 0] == \"recentfile\"} {\n",\ " set filename [lindex $line 1]\n",\ " AddRecentFile $filename\n",\ " }\n",\ " }\n",\ " close $datei\n",\ " }\n",\ "\n",\ "}\n",\ "\n",\ "\n",\ "proc loadmeshinifile { } {\n",\ " if { [file exists ngmesh.ini] == 1 } {\n",\ " set datei [open ngmesh.ini r]\n",\ " while { [gets $datei line] >= 0 } {\n",\ " if {[lindex $line 0] == \"recentfile\"} {\n",\ " set filename [lindex $line 1]\n",\ " AddRecentMeshFile $filename\n",\ " }\n",\ " }\n",\ " close $datei\n",\ " }\n",\ "\n",\ "}\n",\ "\n",\ "\n",\ "proc setgranularity { gran } {\n",\ " if {$gran == 6} { return }\n",\ " set gran [expr $gran - 1]\n",\ " global options.curvaturesafety\n",\ " set surfcurvlist { 1 1.5 2 3 5 }\n",\ " set options.curvaturesafety [lindex $surfcurvlist $gran]\n",\ "\n",\ " global options.segmentsperedge\n",\ " set spelist { 0.3 0.5 1 2 3 }\n",\ " set options.segmentsperedge [lindex $spelist $gran]\n",\ " \n",\ " global stloptions.resthsurfcurvfac\n",\ " set surfcurvfaclist { 0.25 0.5 1 1.5 3 }\n",\ " set stloptions.resthsurfcurvfac [lindex $surfcurvfaclist $gran]\n",\ "\n",\ " global stloptions.resthchartdistfac\n",\ " set chartdistfaclist { 0.8 1 1.5 2 5 }\n",\ " set stloptions.resthchartdistfac [lindex $chartdistfaclist $gran]\n",\ "\n",\ " global stloptions.resthlinelengthfac\n",\ " set linelengthfaclist { 0.2 0.35 0.5 1.5 3 }\n",\ " set stloptions.resthlinelengthfac [lindex $linelengthfaclist $gran]\n",\ "\n",\ " global stloptions.resthcloseedgefac\n",\ " set closeedgefaclist { 0.5 1 2 3.5 5 }\n",\ " set stloptions.resthcloseedgefac [lindex $closeedgefaclist $gran]\n",\ "\n",\ " global stloptions.resthedgeanglefac\n",\ " set edgeanglefaclist { 0.25 0.5 1 1.5 3 }\n",\ " set stloptions.resthedgeanglefac [lindex $edgeanglefaclist $gran]\n",\ "\n",\ "\n",\ " global stloptions.resthsurfmeshcurvfac \n",\ " set surfmeshcurvlist { 1 1.5 2 3 5 }\n",\ " set stloptions.resthsurfmeshcurvfac [lindex $surfmeshcurvlist $gran]\n",\ "\n",\ "\n",\ " global options.grading\n",\ " set gradinglist { 0.7 0.5 0.3 0.2 0.1 }\n",\ " set options.grading [lindex $gradinglist $gran]\n",\ " \n",\ "}\n",\ "\n",\ "\n",\ "if { $batchmode != \"defined\" } {\n",\ " \n",\ "\n",\ "menu .ngmenu -tearoff 0 -relief raised -bd 2\n",\ ". configure -menu .ngmenu\n",\ "\n",\ ".ngmenu add cascade -label \"File\" -menu .ngmenu.file -underline 0\n",\ ".ngmenu add cascade -label \"Geometry\" -menu .ngmenu.geometry -underline 0\n",\ ".ngmenu add cascade -label \"Mesh\" -menu .ngmenu.mesh -underline 0\n",\ ".ngmenu add cascade -label \"View\" -menu .ngmenu.view -underline 0\n",\ ".ngmenu add cascade -label \"Refinement\" -menu .ngmenu.meshsize -underline 5\n",\ "\n",\ "if { $userlevel == 3} {\n",\ " .ngmenu add cascade -label \"Special\" -menu .ngmenu.special -underline 3\n",\ "}\n",\ "\n",\ ".ngmenu add cascade -label \"Help\" -menu .ngmenu.help -underline 0\n",\ "\n",\ "\n",\ "\n",\ "menu .ngmenu.file\n",\ "\n",\ ".ngmenu.file add command -label \"Load Geometry...\" -accelerator \"\" \\\n",\ " -command { \n",\ " set types {\n",\ " {\"All Geometry types\" { .stl .stlb .step .stp .geo .in2d .igs .iges .brep .in2dnew .sat} }\n",\ " {\"IGES Geometry\" {.igs .iges} }\n",\ " {\"BREP OpenCascade Geometry\" {.brep} }\n",\ " {\"STL Geometry\" {.stl} }\n",\ " {\"Binary STL Geometry\" {.stlb} }\n",\ " {\"STEP Geometry\" {.step .stp} }\n",\ " {\"Geometry file\" {.geo} }\n",\ " {\"2D Geometry\" {.in2d } } \n",\ " {\"2D Geometry New\" {.in2dnew } } \n",\ " } \n",\ "\n",\ " set ACISavailable [Ng_ACISCommand isACISavailable]\n",\ " if {$ACISavailable == \"yes\" } {\n",\ " lappend types {\"ACIS Geometry\" {.sat} }\n",\ " }\n",\ "\n",\ " \n",\ "\n",\ "\n",\ " set file [tk_getOpenFile -filetypes $types]\n",\ " if {$file != \"\"} {\n",\ " AddRecentFile $file\n",\ " Ng_LoadGeometry $file \n",\ " Ng_ParseGeometry\n",\ " set selectvisual geometry\n",\ " Ng_SetVisParameters\n",\ " redraw\n",\ " wm title . [concat \"$progname - \" $file]\n",\ " set dirname [file dirname $file]\n",\ " set basefilename [file tail [file rootname $file]]\n",\ "\n",\ " rebuildoccdialog\n",\ " }\n",\ " }\n",\ "\n",\ "\n",\ "\n",\ ".ngmenu.file add command -label \"Save Geometry...\" \\\n",\ " -command { \n",\ " set occgeometryloaded [Ng_OCCCommand isoccgeometryloaded]\n",\ " puts $occgeometryloaded\n",\ " if {$occgeometryloaded == 1 } {\n",\ " set types {\n",\ " {\"IGES Geometry file\" {.igs} } \n",\ " {\"STEP Geometry file\" {.stp} } \n",\ " {\"STL Geometry file\" {.stl} } \n",\ " {\"STL BIN Geometry file\" {.stlb} } \n",\ " }\n",\ " } {\n",\ " set types {\n",\ " {\"STL Geometry file\" {.stl} } \n",\ " {\"STL BIN Geometry file\" {.stlb} } \n",\ " }\n",\ " }\n",\ "\n",\ " set ACISavailable [Ng_ACISCommand isACISavailable]\n",\ " puts $ACISavailable\n",\ " if {$ACISavailable == \"yes\" } {\n",\ " lappend types {\"ACIS Geometry\" {.sat} }\n",\ " }\n",\ "\n",\ "\n",\ "\n",\ " set file [tk_getSaveFile -filetypes $types -initialdir $dirname -initialfile $basefilename ]\n",\ " if {$file != \"\"} {\n",\ " Ng_SaveGeometry $file \n",\ " }\n",\ " }\n",\ " \n",\ "\n",\ "\n",\ ".ngmenu.file add cascade -label \"Recent Files\" -menu .ngmenu.file.recent \n",\ "menu .ngmenu.file.recent\n",\ "\n",\ "\n",\ "proc AddRecentFile { filename } {\n",\ " global progname\n",\ " global dirname\n",\ " catch { [.ngmenu.file.recent delete $filename] }\n",\ " .ngmenu.file.recent insert 0 command -label $filename \\\n",\ " -command \"AddRecentFile {$filename}; \n",\ " Ng_LoadGeometry {$filename}; \n",\ " Ng_ParseGeometry;\n",\ " set selectvisual geometry;\n",\ " Ng_SetVisParameters;\n",\ " redraw;\n",\ " wm title . [concat \\\" $progname - $filename \\\"];\n",\ " set dirname {[file dirname $filename]};\n",\ " set basefilename {[file tail [file rootname $filename]]};\n",\ " rebuildoccdialog;\"\n",\ " \n",\ " if { [.ngmenu.file.recent index last] >= 6 } {\n",\ " .ngmenu.file.recent delete last }\n",\ " \n",\ " saveinifile;\n",\ " }\n",\ "loadinifile;\n",\ "\n",\ "\n",\ ".ngmenu.file add separator\n",\ "\n",\ "\n",\ ".ngmenu.file add command -label \"Load Mesh...\" -accelerator \"\" \\\n",\ " -command {\n",\ " set types {\n",\ " {\"Mesh file\" {.vol} } }\n",\ " set file [tk_getOpenFile -filetypes $types -defaultextension \".vol\"]\n",\ " if {$file != \"\"} {\n",\ " AddRecentMeshFile $file;\n",\ " Ng_LoadMesh $file; \n",\ " set selectvisual mesh\n",\ " Ng_SetVisParameters\n",\ " redraw\n",\ " Ng_ReadStatus; \n",\ " set dirname [file dirname $file]\n",\ " set basefilename [file tail [file rootname $file]]\n",\ " }\n",\ " }\n",\ "\n",\ "\n",\ "\n",\ ".ngmenu.file add cascade -label \"Recent Meshes\" -menu .ngmenu.file.recentmesh \n",\ "menu .ngmenu.file.recentmesh\n",\ "\n",\ "\n",\ "proc AddRecentMeshFile { filename } {\n",\ " global progname\n",\ " global dirname\n",\ " catch { [.ngmenu.file.recentmesh delete $filename] }\n",\ " .ngmenu.file.recentmesh insert 0 command -label $filename \\\n",\ " -command \"AddRecentMeshFile {$filename}; \n",\ " Ng_LoadMesh {$filename};\n",\ " set selectvisual mesh;\n",\ " Ng_SetVisParameters;\n",\ " redraw;\n",\ " wm title . [concat \\\" $progname - $filename \\\"];\n",\ " set dirname {[file dirname $filename]};\n",\ " set basefilename {[file tail [file rootname $filename]]};\n",\ " rebuildoccdialog;\"\n",\ " \n",\ " if { [.ngmenu.file.recentmesh index last] >= 6 } {\n",\ " .ngmenu.file.recentmesh delete last }\n",\ " \n",\ " savemeshinifile;\n",\ " }\n",\ "loadmeshinifile;\n",\ "\n",\ "\n",\ "\n",\ ".ngmenu.file add command -label \"Save Mesh...\" -accelerator \"\" \\\n",\ " -command {\n",\ " set types {\n",\ " {\"Mesh file\" {.vol} } }\n",\ "\n",\ " set file [tk_getSaveFile -filetypes $types -defaultextension \".vol\" -initialfile $basefilename -initialdir $dirname ]\n",\ " if {$file != \"\"} {\n",\ " Ng_SaveMesh $file }\n",\ " AddRecentMeshFile $file;\n",\ "\n",\ " }\n",\ "\n",\ ".ngmenu.file add command -label \"Merge Mesh...\" \\\n",\ " -command {\n",\ " set types {\n",\ " {\"Mesh file\" {.vol} } }\n",\ " set file [tk_getOpenFile -filetypes $types -defaultextension \".vol\"]\n",\ " if {$file != \"\"} {\n",\ " Ng_MergeMesh $file; \n",\ " set selectvisual mesh\n",\ " Ng_SetVisParameters\n",\ " redraw\n",\ " Ng_ReadStatus; \n",\ " }\n",\ " }\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ ".ngmenu.file add command -label \"Import Mesh...\" \\\n",\ " -command { \n",\ " set types {\n",\ " {\"Neutral format\" {.mesh .emt} }\n",\ " {\"Surface mesh format\" {.surf} }\n",\ " {\"Universal format\" {.unv} }\n",\ " {\"Olaf format\" {.emt} }\n",\ " {\"TET format\" {.tet} }\n",\ " {\"Pro/ENGINEER neutral format\" {.fnf} }\n",\ " }\n",\ " set file [tk_getOpenFile -filetypes $types ]\n",\ " if {$file != \"\"} {\n",\ " Ng_ImportMesh $file \n",\ " set selectvisual mesh\n",\ " Ng_SetVisParameters\n",\ " redraw\n",\ " Ng_ReadStatus; \n",\ " }\n",\ " }\n",\ "\n",\ ".ngmenu.file add command -label \"Export Mesh...\" \\\n",\ " -command {\n",\ " if { $exportfiletype == \"Elmer Format\" } {\n",\ " set file [tk_chooseDirectory]\n",\ " } else {\n",\ " set file [tk_getSaveFile]\n",\ " }\n",\ " if {$file != \"\"} {\n",\ " Ng_ExportMesh $file $exportfiletype \n",\ " }\n",\ " }\n",\ "\n",\ ".ngmenu.file add cascade -label \"Export Filetype\" -menu .ngmenu.file.filetype \n",\ "\n",\ "menu .ngmenu.file.filetype \n",\ "\n",\ "\n",\ ".ngmenu.file add separator\n",\ "\n",\ "\n",\ ".ngmenu.file add command -label \"Save Solution...\" \\\n",\ " -command { \n",\ " set types { \n",\ " {\"Solution File\" {.sol} } \n",\ " {\"VTK File\" {.vtk} } \n",\ " }\n",\ " set file [tk_getSaveFile -filetypes $types ]\n",\ " if {$file != \"\"} {\n",\ " Ng_SaveSolution $file \n",\ " }\n",\ " }\n",\ "\n",\ ".ngmenu.file add command -label \"Import Solution...\" \\\n",\ " -command { \n",\ " set types { {\"Solution File\" {.sol} } }\n",\ " set file [tk_getOpenFile -filetypes $types -defaultextension \".sol\" ]\n",\ " if {$file != \"\"} {\n",\ " Ng_ImportSolution $file \n",\ " set selectvisual solution\n",\ " Ng_SetVisParameters\n",\ " redraw\n",\ " }\n",\ " }\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "set demostarttime [clock clicks -millisecond]\n",\ "set stopdemo 0\n",\ "proc demoredraw { } {\n",\ " global demostarttime\n",\ " global stopdemo\n",\ " set curtime [clock clicks -millisecond]\n",\ " set result [ Ng_DemoSetTime [expr $curtime - $demostarttime] ]\n",\ " redraw\n",\ " global videoactive\n",\ " if { $videoactive == 1 } {\n",\ " puts \"addframe\"\n",\ " .ndraw Ng_VideoClip addframe\n",\ " }\n",\ " if { $result == 0 && $stopdemo == 0 } {\n",\ " after 1 { demoredraw }\n",\ " }\n",\ "}\n",\ ".ngmenu.file add command -label \"Show Demo...\" \\\n",\ " -command {\n",\ " set types { {\"Demo File\" {.dem} } }\n",\ " set file [tk_getOpenFile -filetypes $types -defaultextension \".dem\" ]\n",\ " if {$file != \"\"} {\n",\ " Ng_ShowDemo $file \n",\ " set demostarttime [clock clicks -millisecond]\n",\ " set stopdemo 0\n",\ " demoredraw\n",\ " }\n",\ " }\n",\ "\n",\ "\n",\ "\n",\ "\n",\ ".ngmenu.file add separator\n",\ "\n",\ ".ngmenu.file add command -label \"Snapshot...\" \\\n",\ " -command { \n",\ " set types { \n",\ " {\"JPG file\" {.jpg} } \n",\ " {\"GIF file\" {.gif} } \n",\ " {\"PPM file\" {.ppm} } \n",\ " }\n",\ " set file [tk_getSaveFile -filetypes $types]\n",\ " if {$file != \"\"} {\n",\ " .ndraw Ng_SnapShot $file }\n",\ " }\n",\ "\n",\ "\n",\ ".ngmenu.file add cascade -label \"Video clip\" -menu .ngmenu.file.video\n",\ "menu .ngmenu.file.video\n",\ "\n",\ "set videoactive 0\n",\ ".ngmenu.file.video add command -label \"start...\" \\\n",\ " -command { \n",\ " set types { \n",\ " {\"MPG file\" {.mpg} } \n",\ " }\n",\ " set file [tk_getSaveFile -filetypes $types]\n",\ " if {$file != \"\"} {\n",\ " .ndraw Ng_VideoClip init $file \n",\ " global videoactive\n",\ " set videoactive 1\n",\ " }\n",\ " }\n",\ "\n",\ ".ngmenu.file.video add command -label \"add frame...\" \\\n",\ " -command {.ndraw Ng_VideoClip addframe }\n",\ "\n",\ ".ngmenu.file.video add command -label \"one cycle\" \\\n",\ " -command {\n",\ " set visoptions.redrawperiodic 1\n",\ " for { set j 0 } { $j < 100 } { incr j } {\n",\ " puts \"j = $j\"\n",\ " Ng_Vis_Set time [expr (1000 * $j / 100)]\n",\ " redraw\n",\ " .ndraw Ng_VideoClip addframe \n",\ " after 200\n",\ " }\n",\ " }\n",\ "\n",\ ".ngmenu.file.video add command -label \"finalize...\" \\\n",\ " -command {\n",\ " .ndraw Ng_VideoClip finalize \n",\ " global videoactive\n",\ " set videoactive 0\n",\ " }\n",\ "\n",\ "\n",\ "\n",\ ".ngmenu.file add command -label \"Save Options\" \\\n",\ " -command { saveoptions }\n",\ "\n",\ "\n",\ " \n",\ "\n",\ ".ngmenu.file add separator\n",\ "\n",\ "\n",\ ".ngmenu.file add command -label \"Run tests ...\" \\\n",\ " -command { runtestdialog }\n",\ ".ngmenu.file add separator\n",\ "\n",\ ".ngmenu.file add command -label \"Quit\" -accelerator \"\" \\\n",\ " -command { puts \"Thank you for using $progname\"; Ng_Exit; destroy . }\n",\ "\n",\ "\n",\ "\n",\ "menu .ngmenu.mesh\n",\ ".ngmenu.mesh add command -label \"Generate Mesh\" -accelerator \"\" \\\n",\ " -command { \n",\ " Ng_GenerateMesh ${meshoptions.firststep} ${meshoptions.laststep}\n",\ " Ng_ReadStatus\n",\ " set selectvisual mesh\n",\ " Ng_SetVisParameters\n",\ " redraw\n",\ " }\n",\ "\n",\ ".ngmenu.mesh add command -label \"Stop Meshing\" \\\n",\ " -command { Ng_StopMeshing }\n",\ "\n",\ ".ngmenu.mesh add command -label \"Meshing Options...\" \\\n",\ " -command meshingoptionsdialog\n",\ "\n",\ ".ngmenu.mesh add separator\n",\ "\n",\ ".ngmenu.mesh add command -label \"Delete Mesh\" \\\n",\ " -command { Ng_New mesh; Ng_ReadStatus; redraw }\n",\ "\n",\ ".ngmenu.mesh add command -label \"Delete Vol Mesh\" \\\n",\ " -command { Ng_DeleteVolMesh; Ng_ReadStatus; redraw }\n",\ "\n",\ "\n",\ ".ngmenu.mesh add command -label \"Mesh Info\" \\\n",\ " -command {\n",\ " set dim [Ng_MeshInfo dim]\n",\ " set np [Ng_MeshInfo np]\n",\ " set ne [Ng_MeshInfo ne]\n",\ " set nse [Ng_MeshInfo nse]\n",\ " set nseg [Ng_MeshInfo nseg]\n",\ " set bbox [Ng_MeshInfo bbox]\n",\ " 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]\"\n",\ " }\n",\ "\n",\ "\n",\ ".ngmenu.mesh add command -label \"Mesh Quality\" \\\n",\ " -command {\n",\ " set inplanemin 0\n",\ " set inplanemax 0\n",\ " set betplanemin 0\n",\ " set betplanemax 0\n",\ " Ng_MeshQuality inplanemin inplanemax betplanemin betplanemax\n",\ " puts \"Triangle angles : $inplanemin - $inplanemax\"\n",\ " puts \"Tet angles : $betplanemin - $betplanemax\"\n",\ " tk_messageBox -message \"Triangle angles : $inplanemin - $inplanemax \\n Tet angles : $betplanemin - $betplanemax\"\n",\ " }\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ ".ngmenu.mesh add command -label \"Check Surface Mesh\" \\\n",\ " -command { Ng_CheckSurfaceMesh }\n",\ ".ngmenu.mesh add command -label \"Check Volume Mesh\" \\\n",\ " -command { Ng_CheckVolumeMesh }\n",\ "\n",\ ".ngmenu.mesh add command -label \"Edit Boundary Conditions...\" \\\n",\ " -command { bcpropdialog }\n",\ "\n",\ "if { $userlevel == 3 } {\n",\ " .ngmenu.mesh add command -label \"Mesh Doctor...\" \\\n",\ " -command { meshdoctordialog }\n",\ "}\n",\ "\n",\ ".ngmenu.mesh add command -label \"METIS Mesh Partitioning...\" \\\n",\ " -command { METISdialog }\n",\ "\n",\ ".ngmenu.mesh add separator\n",\ "\n",\ ".ngmenu.mesh add command -label \"Analyze Geometry\" \\\n",\ " -command { Ng_GenerateMesh ag ag; Ng_ReadStatus; redraw }\n",\ ".ngmenu.mesh add command -label \"Mesh Edges\" \\\n",\ " -command { Ng_GenerateMesh me me; Ng_ReadStatus; redraw }\n",\ ".ngmenu.mesh add command -label \"Mesh Surface\" \\\n",\ " -command { set selectvisual mesh; Ng_SetVisParameters; \\\n",\ " Ng_GenerateMesh ms ms; Ng_ReadStatus; redraw }\n",\ "\n",\ ".ngmenu.mesh add command -label \"Optimize Surface\" \\\n",\ " -command { Ng_GenerateMesh os os cmsmSm; redraw }\n",\ "\n",\ ".ngmenu.mesh add cascade -label \"Surface Optim. Step\" -menu .ngmenu.mesh.surfoptstep \n",\ "\n",\ "menu .ngmenu.mesh.surfoptstep \n",\ ".ngmenu.mesh.surfoptstep add command -label \"Mesh Smoothing\" \\\n",\ " -command { Ng_GenerateMesh os os m; redraw}\n",\ ".ngmenu.mesh.surfoptstep add command -label \"Edge swapping (topologic)\" \\\n",\ " -command { Ng_GenerateMesh os os s; redraw}\n",\ ".ngmenu.mesh.surfoptstep add command -label \"Edge swapping (metric)\" \\\n",\ " -command { Ng_GenerateMesh os os S; redraw}\n",\ ".ngmenu.mesh.surfoptstep add command -label \"Combine points\" \\\n",\ " -command { Ng_GenerateMesh os os c; redraw}\n",\ "\n",\ "\n",\ ".ngmenu.mesh add separator\n",\ ".ngmenu.mesh add command -label \"Mesh Volume\" \\\n",\ " -command { Ng_GenerateMesh mv mv; Ng_ReadStatus }\n",\ ".ngmenu.mesh add command -label \"Optimize Volume\" \\\n",\ " -command { Ng_GenerateMesh ov ov; Ng_ReadStatus }\n",\ ".ngmenu.mesh add command -label \"Smooth Opt Volume\" \\\n",\ " -command { Ng_GenerateMesh ov ov m; Ng_ReadStatus }\n",\ ".ngmenu.mesh add command -label \"Smooth Opt Volume Jacobian\" \\\n",\ " -command { Ng_GenerateMesh ov ov j; Ng_ReadStatus }\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "menu .ngmenu.geometry\n",\ ".ngmenu.geometry add command -label \"Scan CSG Geometry\" -command { Ng_ParseGeometry }\n",\ ".ngmenu.geometry add command -label \"CSG Options...\" -command geometryoptionsdialog\n",\ ".ngmenu.geometry add command -label \"CSG Properties...\" \\\n",\ " -command topleveldialog2 \n",\ "\n",\ ".ngmenu.geometry add separator\n",\ "\n",\ ".ngmenu.geometry add command -label \"STL Doctor...\" \\\n",\ " -command { stldoctordialog; }\n",\ "\n",\ ".ngmenu.geometry add command -label \"STL Info\" \\\n",\ " -command {\n",\ " set notriangles 0\n",\ " set minx 0\n",\ " set maxx 0\n",\ " set miny 0\n",\ " set maxy 0\n",\ " set minz 0\n",\ " set maxz 0\n",\ " set trigscons 0\n",\ " Ng_STLInfo notriangles minx maxx miny maxy minz maxz trigscons\n",\ " set msgtext \"NO STL-Triangles : $notriangles\\nGeometry:\\nX = $minx - $maxx\\nY = $miny - $maxy\\nZ = $minz - $maxz\\nConsistency Check = $trigscons\\n\"\n",\ " set msgtext \"$msgtext Status: [Ng_STLInfo status]\"\n",\ " tk_messageBox -title \"STL Info\" -message $msgtext -type ok \n",\ " }\n",\ "\n",\ ".ngmenu.geometry add separator\n",\ "\n",\ ".ngmenu.geometry add command -label \"IGES/STEP Topology Explorer/Doctor...\" \\\n",\ " -command { occdialog; }\n",\ "\n",\ "\n",\ ".ngmenu.geometry add command -label \"OCC Construction\" \\\n",\ " -command { Ng_OCCConstruction; }\n",\ "\n",\ "if { [Ng_ACISCommand isACISavailable] == \"yes\" } {\n",\ " .ngmenu.geometry add command -label \"ACIS Topology Explorer...\" \\\n",\ " -command { acisdialog; }\n",\ "\n",\ " .ngmenu.geometry add command -label \"ACIS combine all\" \\\n",\ " -command { Ng_ACISCommand combineall }\n",\ " .ngmenu.geometry add command -label \"ACIS Create CT\" \\\n",\ " -command { Ng_ACISCommand createct }\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "menu .ngmenu.view\n",\ ".ngmenu.view add command -label \"Zoom all\" \\\n",\ " -command { Ng_ZoomAll; redraw }\n",\ ".ngmenu.view add command -label \"Center\" \\\n",\ " -command { Ng_Center; redraw }\n",\ "\n",\ ".ngmenu.view add command -label \"x-y plane\" \\\n",\ " -command { Ng_StandardRotation xy; redraw }\n",\ ".ngmenu.view add command -label \"y-x plane\" \\\n",\ " -command { Ng_StandardRotation yx; redraw }\n",\ ".ngmenu.view add command -label \"x-z plane\" \\\n",\ " -command { Ng_StandardRotation xz; redraw }\n",\ ".ngmenu.view add command -label \"z-x plane\" \\\n",\ " -command { Ng_StandardRotation zx; redraw }\n",\ ".ngmenu.view add command -label \"y-z plane\" \\\n",\ " -command { Ng_StandardRotation yz; redraw }\n",\ ".ngmenu.view add command -label \"z-y plane\" \\\n",\ " -command { Ng_StandardRotation zy; redraw }\n",\ "\n",\ ".ngmenu.view add command -label \"Viewing Options...\" \\\n",\ " -command { viewingoptionsdialog; redraw }\n",\ ".ngmenu.view add command -label \"Clipping Plane...\" \\\n",\ " -command { clippingdialog; redraw }\n",\ ".ngmenu.view add command -label \"Solution Data...\" \\\n",\ " -command { visual_dialog; redraw }\n",\ ".ngmenu.view add checkbutton -variable viewqualityplot \\\n",\ " -label \"Quality Plot\" \\\n",\ " -command { qualityviewdialog $viewqualityplot }\n",\ ".ngmenu.view add checkbutton -variable memuseplot \\\n",\ " -label \"Memory Usage\" \\\n",\ " -command { memusedialog $memuseplot }\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "menu .ngmenu.meshsize\n",\ ".ngmenu.meshsize add command -label \"Refine uniform\" \\\n",\ " -command { Ng_Refine; Ng_HighOrder ${options.elementorder}; Ng_ReadStatus; redraw }\n",\ "\n",\ ".ngmenu.meshsize add command -label \"Second Order\" \\\n",\ " -command { Ng_SecondOrder; Ng_ReadStatus; redraw }\n",\ "\n",\ ".ngmenu.meshsize add command -label \"Validate Second Order\" \\\n",\ " -command { Ng_ValidateSecondOrder; Ng_ReadStatus; redraw }\n",\ "\n",\ ".ngmenu.meshsize add command -label \"High Order\" \\\n",\ " -command { Ng_HighOrder ${options.elementorder}; Ng_ReadStatus; redraw }\n",\ "\n",\ ".ngmenu.meshsize add separator\n",\ "\n",\ ".ngmenu.meshsize add command -label \"Refinement Dialog...\" \\\n",\ " -command { refinementdialog }\n",\ ".ngmenu.meshsize add command -label \"Load Meshsize...\" \\\n",\ " -command {\n",\ " set types {\n",\ " {\"Meshsize file\" {.msz} } }\n",\ " set file [tk_getOpenFile -filetypes $types]\n",\ " if {$file != \"\"} {\n",\ " Ng_LoadMeshSize $file; \n",\ " }\n",\ " }\n",\ ".ngmenu.meshsize add command -label \"MS from Surf Mesh\" \\\n",\ " -command { Ng_MeshSizeFromSurfaceMesh }\n",\ "\n",\ "\n",\ "if { $userlevel == 3 } {\n",\ ".ngmenu.meshsize add command -label \"Singular point ms\" \\\n",\ " -command { Ng_SingularPointMS; }\n",\ "\n",\ ".ngmenu.meshsize add command -label \"Singular edge ms\" \\\n",\ " -command { Ng_SingularEdgeMS; }\n",\ "\n",\ ".ngmenu.meshsize add separator\n",\ "\n",\ "set bisectfilename \"\";\n",\ "\n",\ ".ngmenu.meshsize add command -label \"Bisection\" \\\n",\ " -command { Ng_ReadStatus; set oldnp 0; set newnp $status_np; \n",\ " Ng_ReadStatus;\n",\ " \n",\ " while { $oldnp < $newnp } {\n",\ " set level [expr $level+1]\n",\ " if { $bisectfilename == \"\"} {\n",\ " Ng_Bisect;\n",\ " } else {\n",\ " Ng_Bisect $bisectfilename;\n",\ " }\n",\ " Ng_ReadStatus;\n",\ " redraw; \n",\ " \n",\ " if { $bisectfilename == \"\"} {\n",\ " set oldnp $newnp;\n",\ " set newnp $status_np;\n",\ " puts \"oldnp $oldnp newnp $newnp\";\n",\ " } else {\n",\ " set oldnp $newnp;\n",\ " }\n",\ " }\n",\ " }\n",\ "\n",\ "}\n",\ "\n",\ ".ngmenu.meshsize add command -label \"Load Refinement Info...\" \\\n",\ " -command {\n",\ " set types {\n",\ " {\"Refinement info\" {.refine} }}\n",\ " set bisectfilename [tk_getOpenFile -filetypes $types]\n",\ " }\n",\ "\n",\ ".ngmenu.meshsize add command -label \"Z-Refinement\" \\\n",\ " -command { Ng_ZRefinement 2; Ng_ReadStatus; redraw }\n",\ "\n",\ "\n",\ "\n",\ ".ngmenu.meshsize add cascade -label \"hp-Refinement\" -menu .ngmenu.meshsize.hpref\n",\ "menu .ngmenu.meshsize.hpref\n",\ ".ngmenu.meshsize.hpref add command -label \"1 Level\" \\\n",\ " -command { Ng_HPRefinement 1; Ng_ReadStatus; redraw }\n",\ ".ngmenu.meshsize.hpref add command -label \"2 Levels\" \\\n",\ " -command { Ng_HPRefinement 2; Ng_ReadStatus; redraw }\n",\ ".ngmenu.meshsize.hpref add command -label \"3 Levels\" \\\n",\ " -command { Ng_HPRefinement 3; Ng_ReadStatus; redraw }\n",\ ".ngmenu.meshsize.hpref add command -label \"4 Levels\" \\\n",\ " -command { Ng_HPRefinement 4; Ng_ReadStatus; redraw }\n",\ ".ngmenu.meshsize.hpref add command -label \"5 Levels\" \\\n",\ " -command { Ng_HPRefinement 5; Ng_ReadStatus; redraw }\n",\ ".ngmenu.meshsize.hpref add command -label \"6 Levels\" \\\n",\ " -command { Ng_HPRefinement 6; Ng_ReadStatus; redraw }\n",\ ".ngmenu.meshsize.hpref add command -label \"7 Levels\" \\\n",\ " -command { Ng_HPRefinement 7; Ng_ReadStatus; redraw }\n",\ ".ngmenu.meshsize.hpref add command -label \"8 Levels\" \\\n",\ " -command { Ng_HPRefinement 8; Ng_ReadStatus; redraw }\n",\ ".ngmenu.meshsize.hpref add command -label \"9 Levels\" \\\n",\ " -command { Ng_HPRefinement 9; Ng_ReadStatus; redraw }\n",\ ".ngmenu.meshsize.hpref add command -label \"10 Levels\" \\\n",\ " -command { Ng_HPRefinement 10; Ng_ReadStatus; redraw }\n",\ "\n",\ "\n",\ ".ngmenu.meshsize add command -label \"Split to Tets\" \\\n",\ " -command { Ng_Split2Tets; Ng_ReadStatus; redraw }\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "menu .ngmenu.special\n",\ ".ngmenu.special add command -label \"Insert virtual boundary layer\" \\\n",\ " -command { Ng_InsertVirtualBL; redraw }\n",\ ".ngmenu.special add command -label \"Cut off and combine with other\" \\\n",\ " -command { \n",\ " set types { {\"Mesh file\" {.vol} } }\n",\ " set file [tk_getOpenFile -filetypes $types]\n",\ " if {$file != \"\"} {\n",\ " Ng_CutOffAndCombine $file; }\n",\ " redraw \n",\ " }\n",\ ".ngmenu.special add command -label \"Helmholtz Mesh grading\" \\\n",\ " -command { Ng_HelmholtzMesh; }\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "menu .ngmenu.help\n",\ ".ngmenu.help add command -label \"Ng Help...\" \\\n",\ " -command { help_main }\n",\ ".ngmenu.view add checkbutton -label \"Help Line\" -variable showhelpline \\\n",\ " -command {\n",\ " if { $showhelpline == 1} {\n",\ " pack .helpline -before .statbar -side bottom -fill x -padx 3p\n",\ " } {\n",\ " pack forget .helpline \n",\ " }\n",\ "} \n",\ "\n",\ ".ngmenu.help add command -label \"About...\" \\\n",\ " -command {\n",\ "tk_messageBox -message \"This is NETGEN \\n mainly written by \\n Joachim Schöberl \\n thanks to \\n R. Gaisbauer, J. Gerstmayr\"\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "frame .bubar -relief raised -bd 2\n",\ "pack .bubar -side top -fill x\n",\ "\n",\ "button .bubar.testb -text \"Test\" -command { Ng_SaveGeometry }\n",\ "button .bubar.surfm -text \"Generate Mesh\" -command \\\n",\ " { set selectvisual mesh; \n",\ " Ng_SetVisParameters;\n",\ " Ng_GenerateMesh ${meshoptions.firststep} ${meshoptions.laststep}\n",\ " redraw \n",\ " }\n",\ "button .bubar.stopm -text \"Stop\" -command \\\n",\ " { Ng_StopMeshing; set stopdemo 1 }\n",\ "button .bubar.exitb -text \"Quit\" \\\n",\ " -command { .ngmenu.file invoke \"Quit\" }\n",\ "pack .bubar.exitb .bubar.surfm .bubar.stopm -side left\n",\ "\n",\ "\n",\ "Ng_IsParallel;\n",\ "if { $parallel_netgen } {\n",\ " button .bubar.visallb -text \"Parallel\" -command \\\n",\ " { paralleldialog; redraw } \n",\ " pack .bubar.visallb -side left \n",\ "}\n",\ "\n",\ "button .bubar.zoomall -text \"Zoom All\" \\\n",\ " -command { Ng_ZoomAll; redraw }\n",\ "\n",\ "button .bubar.center -text \"Center\" \\\n",\ " -command { Ng_Center; redraw }\n",\ "\n",\ "tixOptionMenu .bubar.modesel \\\n",\ " -options {\n",\ " label.width 0\n",\ " label.anchor e\n",\ " menubutton.width 6\n",\ " } \\\n",\ " -variable drawmode\n",\ "\n",\ ".bubar.modesel add command rotate -label Rotate\n",\ ".bubar.modesel add command move -label Move\n",\ ".bubar.modesel add command zoom -label Zoom\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "set viewvals { geometry specpoints mesh solution}\n",\ "if { $userlevel == 3} {\n",\ " set viewvals { geometry mesh specpoints surfmeshing modelview solution}\n",\ "}\n",\ "\n",\ "set viewvallabs(cross) \"Cross\" \n",\ "set viewvallabs(geometry) \"Geometry\" \n",\ "set viewvallabs(mesh) \"Mesh\" \n",\ "set viewvallabs(specpoints) \"Edges\" \n",\ "set viewvallabs(surfmeshing) \"Mesh Gen\" \n",\ "set viewvallabs(modelview) \"Modeller\" \n",\ "set viewvallabs(solution) \"Solution\" \n",\ "\n",\ "tixOptionMenu .bubar.selview \\\n",\ " -options {\n",\ " label.width 0\n",\ " label.anchor e\n",\ " menubutton.width 10\n",\ " } \\\n",\ "\n",\ "foreach viewv $viewvals {\n",\ " .bubar.selview add command $viewv -label $viewvallabs($viewv)\n",\ "}\n",\ "\n",\ "\n",\ ".bubar.selview config -variable selectvisual\n",\ ".bubar.selview config -command { Ng_SetVisParameters; redraw }\n",\ "\n",\ "\n",\ "pack .bubar.modesel -side right\n",\ "pack forget .bubar.modesel\n",\ "pack .bubar.center .bubar.zoomall .bubar.selview -side right\n",\ "\n",\ ".ngmenu.view add checkbutton -variable viewrotatebutton \\\n",\ " -label \"Enable LeftButton Selection\" \\\n",\ " -command { \n",\ " if { $viewrotatebutton } {\n",\ " pack .bubar.modesel -side right\n",\ " } {\n",\ " pack forget .bubar.modesel\n",\ " }\n",\ " }\n",\ "\n",\ "\n",\ "\n",\ "label .helpline -text \"None\"\n",\ "pack forget .helpline -side bottom -fill x\n",\ "\n",\ "frame .statbar -relief flat -bd 2\n",\ "pack .statbar -side bottom -fill x\n",\ "\n",\ "label .statbar.ptslabel -text \"Points: \"\n",\ "label .statbar.ptsval -textvariable status_np\n",\ "label .statbar.elslabel -text \" Elements: \"\n",\ "label .statbar.elsval -textvariable status_ne\n",\ "label .statbar.selslabel -text \" Surf Elements: \"\n",\ "label .statbar.selsval -textvariable status_nse\n",\ "label .statbar.task -textvariable status_task\n",\ "\n",\ "pack .statbar.ptslabel .statbar.ptsval -side left -ipady 3p \n",\ "pack .statbar.elslabel .statbar.elsval -side left -ipady 3p \n",\ "pack .statbar.selslabel .statbar.selsval -side left -ipady 3p\n",\ "\n",\ "\n",\ "\n",\ "tixMeter .statbar.per -value 0 -text 0%\n",\ ".statbar.per configure -fillcolor blue\n",\ "\n",\ "pack .statbar.per -side right\n",\ "pack .statbar.task -side right -ipady 4\n",\ "\n",\ "set qualbaraxis(0) 0\n",\ "set qualbar(0) 0\n",\ "set qualbarnull(0) 0\n",\ "\n",\ "\n",\ "\n",\ "proc timer2 { } {\n",\ " global status_np\n",\ " global status_ne\n",\ " global status_nse\n",\ " global multithread_running\n",\ " global multithread_redraw\n",\ " global status_working\n",\ " global status_task\n",\ " global status_percent\n",\ " global status_tetqualclasses\n",\ " \n",\ "\n",\ " Ng_ReadStatus \n",\ "\n",\ " if { $multithread_redraw == 1 } {\n",\ " set multithread_redraw 0;\n",\ " redraw;\n",\ " \n",\ " global videoactive\n",\ " if { $videoactive == 1 } {\n",\ " puts \"addframe\"\n",\ " .ndraw Ng_VideoClip addframe\n",\ " }\n",\ " }\n",\ "\n",\ " global mem_moveable\n",\ " set mem_moveable [Ng_MemInfo moveable]\n",\ "\n",\ "\n",\ " .statbar.per config -value [expr $status_percent/100] -text [format %2.1f [expr 0.1*int(10*$status_percent)]]%\n",\ "\n",\ "\n",\ " if { $multithread_running } {\n",\ " pack .statbar.per -side right -before .statbar.task -padx 6\n",\ " } { \n",\ " pack forget .statbar.per\n",\ " }\n",\ " \n",\ "\n",\ "\n",\ " if {[winfo exists .qualityview_dlg] == 1} {\n",\ " \n",\ " global qualbar\n",\ " global qualbarnull\n",\ " global qualbaraxis\n",\ "\n",\ " set maxval 0\n",\ " for {set i 0} {$i < 20} {incr i} {\n",\ " if {[lindex $status_tetqualclasses $i] > $maxval} {\n",\ " set maxval [lindex $status_tetqualclasses $i]\n",\ " }\n",\ " } \n",\ "\n",\ " set ubound 1\n",\ " while { $ubound < $maxval } {\n",\ " set ubound [expr {10 * $ubound}]\n",\ " }\n",\ " if { $ubound/5 > $maxval } {\n",\ " set ubound [expr $ubound/5]\n",\ " }\n",\ " if { $ubound/2 > $maxval } {\n",\ " set ubound [expr $ubound/2]\n",\ " }\n",\ "\n",\ "\n",\ " \n",\ " for {set i 1} {$i <= 5} {incr i} {\n",\ " \n",\ " set value [expr { $i * $ubound / 5 }]\n",\ " .qualityview_dlg.c dchars $qualbaraxis($i) 0 end\n",\ " .qualityview_dlg.c insert $qualbaraxis($i) end $value \n",\ " }\n",\ "\n",\ " \n",\ " for {set i 0} {$i < 20} {incr i} {\n",\ " set x1 [expr {100 + ($i*15) + 2}]\n",\ " set x2 [expr {$x1+10}]\n",\ " \n",\ " set nbrs [lindex $status_tetqualclasses $i]\n",\ " set y [expr (249 - (200 * $nbrs / $ubound ) )]\n",\ " \n",\ " .qualityview_dlg.c coords $qualbar($i) $x1 250 $x2 $y\n",\ "\n",\ " if { $nbrs == 0 } {\n",\ " .qualityview_dlg.c itemconfigure $qualbarnull($i) -text 0\n",\ " } {\n",\ " .qualityview_dlg.c itemconfigure $qualbarnull($i) -text \"\" \n",\ " } \n",\ " }\n",\ " \n",\ " }\n",\ "\n",\ "\n",\ "\n",\ " if {[winfo exists .memuse_dlg] == 1} { \n",\ " \n",\ " global memmark\n",\ " set usemb [Ng_MemInfo usedmb]\n",\ " for {set i 0} {$i < [string length $usemb] } {incr i} {\n",\ " if { [string index $usemb $i] == 0 } {\n",\ " .memuse_dlg.c coords $memmark($i) [expr 50+$i] 68 [expr 50+$i] 70\n",\ " } {\n",\ " .memuse_dlg.c coords $memmark($i) [expr 50+$i] 50 [expr 50+$i] 70\n",\ " }\n",\ " }\n",\ "\n",\ " }\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ " after 200 { timer2 }\n",\ "}\n",\ "timer2\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "proc bgerror { error } {\n",\ " global errorInfo userlevel\n",\ " if { $userlevel == 3} {\n",\ " puts \"ERROR: $error\" \n",\ " puts \"errinfo: $errorInfo\"\n",\ " }\n",\ " tk_messageBox -title \"Error Message\" -message $error -type ok \n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "proc smh2 { menuitem } {\n",\ " if {[catch {$menuitem entrycget active -label} name]} {\n",\ " set name \" \"\n",\ " } \n",\ " show_menu_help $name \n",\ " update idletasks\n",\ "}\n",\ "\n",\ "bind .ngmenu <> { smh2 %W }\n",\ "bind .ngmenu.file <> { smh2 %W }\n",\ "bind .ngmenu.geometry <> { smh2 %W }\n",\ "bind .ngmenu.mesh <> { smh2 %W }\n",\ "bind .ngmenu.view <> { smh2 %W }\n",\ "bind .ngmenu.meshsize <> { smh2 %W }\n",\ "bind .ngmenu.special <> { smh2 %W }\n",\ "bind .ngmenu.help <> { smh2 %W }\n",\ "\n",\ "\n",\ "bind . { .ngmenu.file invoke \"Quit\" }\n",\ "bind . { .ngmenu.file invoke \"Load Geometry...\" } ; \n",\ "bind . { .ngmenu.file invoke \"Load Mesh...\" } ;\n",\ "bind . { .ngmenu.file invoke \"Save Mesh...\" } ;\n",\ "bind . { .ngmenu.file activate \"Recent Files\" } ;\n",\ "bind .

{ newprimitivedialog } ; bind .

{ editprimitivedialog }\n",\ "bind . { newsoliddialog }\n",\ "bind . { .ngmenu.mesh invoke \"Generate Mesh\" } ;\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "proc meshingoptionsdialog { } {\n",\ "\n",\ " set w .options_dlg\n",\ " \n",\ " if {[winfo exists .options_dlg] == 1} {\n",\ " wm withdraw $w\n",\ " wm deiconify $w\n",\ " focus $w \n",\ " } {\n",\ "\n",\ " toplevel $w\n",\ "\n",\ "\n",\ " tixNoteBook $w.nb -ipadx 6 -ipady 6\n",\ " \n",\ " $w.nb add general -label \"General\" -underline 0\n",\ " $w.nb add meshsize -label \"Mesh Size\" -underline 0\n",\ " $w.nb add chartopt -label \"STL Charts\" -underline 0\n",\ " $w.nb add optimizer -label \"Optimizer\" -underline 0\n",\ " $w.nb add insider -label \"Insider\" -underline 0\n",\ " $w.nb add debug -label \"Debug\" -underline 0\n",\ "\n",\ "\n",\ " pack $w.nb -expand yes -fill both -padx 5 -pady 5 -side top \n",\ "\n",\ "\n",\ " \n",\ " set f [$w.nb subwidget general]\n",\ "\n",\ " set finevals { 1 2 3 4 5 6 }\n",\ " set finelabs(1) \"very coarse\" \n",\ " set finelabs(2) \"coarse\" \n",\ " set finelabs(3) \"moderate\" \n",\ " set finelabs(4) \"fine\" \n",\ " set finelabs(5) \"very fine\" \n",\ " set finelabs(6) \"user defined\"\n",\ "\n",\ " tixOptionMenu $f.fine -label \"Mesh granularity : \" \\\n",\ " -options {\n",\ " label.width 19\n",\ " label.anchor e\n",\ " menubutton.width 15\n",\ " } \n",\ "\n",\ "\n",\ " foreach finev $finevals {\n",\ " $f.fine add command $finev -label $finelabs($finev)\n",\ " }\n",\ " $f.fine config -variable meshoptions.fineness\n",\ " $f.fine config -command { setgranularity }\n",\ " global meshoptions.fineness\n",\ " pack $f.fine\n",\ "\n",\ "\n",\ " \n",\ "\n",\ "\n",\ " set mgsteps { ag me ms os mv ov }\n",\ " set mgsteplabel(ag) \"Analyze Geometry\"\n",\ " set mgsteplabel(me) \"Mesh Edges\"\n",\ " set mgsteplabel(ms) \"Mesh Surface\"\n",\ " set mgsteplabel(os) \"Optimize Surface\"\n",\ " set mgsteplabel(mv) \"Mesh Volume\"\n",\ " set mgsteplabel(ov) \"Optimize Volume\"\n",\ "\n",\ " \n",\ " tixOptionMenu $f.first -label \"First Step : \" \\\n",\ " -options {\n",\ " label.width 19\n",\ " label.anchor e\n",\ " menubutton.width 15\n",\ " } \n",\ "\n",\ " tixOptionMenu $f.last -label \"Last Step : \" \\\n",\ " -options {\n",\ " label.width 19\n",\ " label.anchor e\n",\ " menubutton.width 15\n",\ " } \n",\ "\n",\ " foreach step $mgsteps {\n",\ " $f.first add command $step -label $mgsteplabel($step)\n",\ " $f.last add command $step -label $mgsteplabel($step)\n",\ " }\n",\ "\n",\ " $f.first config -variable meshoptions.firststep \n",\ " $f.last config -variable meshoptions.laststep \n",\ "\n",\ " pack $f.first $f.last\n",\ " \n",\ "\n",\ "\n",\ "\n",\ "\n",\ " set msg(0) \"None\"\n",\ " set msg(1) \"Least\"\n",\ " set msg(2) \"Little\"\n",\ " set msg(3) \"Moderate\"\n",\ " set msg(4) \"Much\"\n",\ " set msg(5) \"Most\"\n",\ " \n",\ " tixOptionMenu $f.msg -label \"Print Messages : \" \\\n",\ " -options {\n",\ " label.width 19\n",\ " label.anchor e\n",\ " menubutton.width 15\n",\ " } \n",\ "\n",\ " foreach step {0 1 2 3 4 5 } {\n",\ " $f.msg add command $step -label $msg($step)\n",\ " }\n",\ "\n",\ " $f.msg config -variable options.printmsg \n",\ " pack $f.msg\n",\ " \n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ " \n",\ "\n",\ " checkbutton $f.parthread -text \"Parallel meshing thread\" \\\n",\ " -variable options.parthread\n",\ " checkbutton $f.second -text \"Second order elements\" \\\n",\ " -variable options.secondorder\n",\ " checkbutton $f.quad -text \"Quad dominated\" \\\n",\ " -variable options.quad -command {\n",\ " if { ${options.quad} } {\n",\ " set meshoptions.laststep os\n",\ " }\n",\ " }\n",\ " checkbutton $f.invtets -text \"Invert volume elements\" \\\n",\ " -variable options.inverttets\n",\ " checkbutton $f.invtrigs -text \"Invert surface elements\" \\\n",\ " -variable options.inverttrigs\n",\ " checkbutton $f.azref -text \"Automatic Z-refinement\" \\\n",\ " -variable options.autozrefine\n",\ "\n",\ " pack $f.parthread $f.second $f.quad $f.invtets $f.invtrigs $f.azref \n",\ "\n",\ "\n",\ "\n",\ " tixControl $f.elementorder -label \"Element order: \" -integer true \\\n",\ " -variable options.elementorder -min 1 -max 20 \\\n",\ " -options {\n",\ " entry.width 2\n",\ " label.width 20\n",\ " label.anchor e\n",\ " } \n",\ "\n",\ " pack $f.elementorder\n",\ "\n",\ "\n",\ " tixControl $f.memory -label \"Large Memory \\[MB\\]: \" -integer true \\\n",\ " -variable options.memory -min 0 -max 2000 \\\n",\ " -options {\n",\ " entry.width 5\n",\ " label.width 20\n",\ " label.anchor e\n",\ " } \n",\ "\n",\ " global userlevel\n",\ " if { $userlevel >= 3} { pack $f.memory }\n",\ "\n",\ "\n",\ " set f [$w.nb subwidget meshsize]\n",\ "\n",\ " tixControl $f.meshsize -label \"max mesh-size: \" -integer false \\\n",\ " -variable options.meshsize -min 1e-9 -max 1e6 \\\n",\ " -options {\n",\ " entry.width 6\n",\ " label.width 25\n",\ " label.anchor e\n",\ " } \n",\ "\n",\ " tixControl $f.minmeshsize -label \"min mesh-size: \" -integer false \\\n",\ " -variable options.minmeshsize -min 0 -max 1e6 \\\n",\ " -options {\n",\ " entry.width 6\n",\ " label.width 25\n",\ " label.anchor e\n",\ " } \n",\ "\n",\ " tixControl $f.grading -label \"mesh-size grading: \" -integer false \\\n",\ " -variable options.grading -min 0.1 -max 1 -step 0.1 \\\n",\ " -options {\n",\ " entry.width 6\n",\ " label.width 25\n",\ " label.anchor e\n",\ " } \n",\ " \n",\ " pack $f.meshsize $f.minmeshsize $f.grading\n",\ "\n",\ "\n",\ "\n",\ " frame $f.msf \n",\ " pack $f.msf\n",\ "\n",\ " tixLabelEntry $f.msf.ent -label \"mesh-size file: \" \\\n",\ " -labelside top \\\n",\ " -options { \n",\ " entry.textVariable options.meshsizefilename \n",\ " entry.width 35\n",\ " label.width 25\n",\ " label.anchor w\n",\ " } \n",\ " button $f.msf.btn -text \"Browse\" -command {\n",\ " global options.meshsizefilename\n",\ " set types {\n",\ " {\"Meshsize file\" {.msz} } }\n",\ " set options.meshsizefilename [tk_getOpenFile -filetypes $types -initialfile ${options.meshsizefilename}]\n",\ " }\n",\ "\n",\ " pack $f.msf.ent -side left -expand yes -fill x -anchor s -padx 4 -pady 4\n",\ " pack $f.msf.btn -side left -anchor s -padx 4 -pady 4\n",\ "\n",\ "\n",\ " label $f.lab -text \"Additional mesh size restrictions:\"\n",\ "\n",\ " \n",\ " frame $f.csg -relief groove -borderwidth 3\n",\ " pack $f.csg -fill x\n",\ "\n",\ "\n",\ " frame $f.csg.curv\n",\ " pack $f.csg.curv -anchor w\n",\ "\n",\ " scale $f.csg.curv.sc -orient horizontal -length 200 -from 0.2 -to 5 \\\n",\ " -resolution 0.1 -variable options.curvaturesafety\n",\ " label $f.csg.curv.la -text \"Elements per curvature radius\"\n",\ " pack $f.csg.curv.sc $f.csg.curv.la -side left \n",\ "\n",\ " frame $f.csg.elen\n",\ " pack $f.csg.elen -anchor w\n",\ " scale $f.csg.elen.sc -orient horizontal -length 200 -from 0.2 -to 5 \\\n",\ " -resolution 0.1 -variable options.segmentsperedge\n",\ " label $f.csg.elen.la -text \"Elements per edge\"\n",\ " pack $f.csg.elen.sc $f.csg.elen.la -side left\n",\ " \n",\ "\n",\ " \n",\ " frame $f.stl -relief groove -borderwidth 3\n",\ " pack $f.stl -fill x\n",\ "\n",\ " frame $f.stl.r2\n",\ " pack $f.stl.r2 -anchor w\n",\ " scale $f.stl.r2.sc -orient horizontal -length 200 -from 0.2 -to 5 \\\n",\ " -resolution 0.1 -variable stloptions.resthchartdistfac\n",\ " checkbutton $f.stl.r2.bu -text \"STL - chart distance\" \\\n",\ " -variable stloptions.resthchartdistenable\n",\ " pack $f.stl.r2.sc $f.stl.r2.bu -side left\n",\ " \n",\ " frame $f.stl.r6\n",\ " pack $f.stl.r6 -anchor w\n",\ " scale $f.stl.r6.sc -orient horizontal -length 200 -from 0.2 -to 5 \\\n",\ " -resolution 0.1 -variable stloptions.resthlinelengthfac\n",\ " checkbutton $f.stl.r6.bu -text \"STL - line length\" \\\n",\ " -variable stloptions.resthlinelengthenable\n",\ " pack $f.stl.r6.sc $f.stl.r6.bu -side left\n",\ " \n",\ " frame $f.stl.r3\n",\ " pack $f.stl.r3 -anchor w\n",\ " scale $f.stl.r3.sc -orient horizontal -length 200 -from 0.2 -to 8 \\\n",\ " -resolution 0.1 -variable stloptions.resthcloseedgefac\n",\ " checkbutton $f.stl.r3.bu -text \"STL/IGES/STEP - close edges\" \\\n",\ " -variable stloptions.resthcloseedgeenable\n",\ " pack $f.stl.r3.sc $f.stl.r3.bu -side left\n",\ " \n",\ " frame $f.stl.r1\n",\ " pack $f.stl.r1 -anchor w\n",\ " scale $f.stl.r1.sc -orient horizontal -length 200 -from 0.2 -to 5 \\\n",\ " -resolution 0.1 -variable stloptions.resthsurfcurvfac\n",\ " checkbutton $f.stl.r1.bu -text \"STL - surface curvature\" \\\n",\ " -variable stloptions.resthsurfcurvenable\n",\ " pack $f.stl.r1.sc $f.stl.r1.bu -side left\n",\ "\n",\ " frame $f.stl.r3b\n",\ " pack $f.stl.r3b -anchor w\n",\ " scale $f.stl.r3b.sc -orient horizontal -length 200 -from 0.2 -to 5 \\\n",\ " -resolution 0.1 -variable stloptions.resthedgeanglefac\n",\ " checkbutton $f.stl.r3b.bu -text \"STL - edge angle\" \\\n",\ " -variable stloptions.resthedgeangleenable\n",\ " pack $f.stl.r3b.sc $f.stl.r3b.bu -side left\n",\ " \n",\ " frame $f.stl.r5\n",\ " pack $f.stl.r5 -anchor w\n",\ " scale $f.stl.r5.sc -orient horizontal -length 200 -from 0.2 -to 5 \\\n",\ " -resolution 0.1 -variable stloptions.resthsurfmeshcurvfac\n",\ " checkbutton $f.stl.r5.bu -text \"STL - surface mesh curv\" \\\n",\ " -variable stloptions.resthsurfmeshcurvenable\n",\ " pack $f.stl.r5.sc $f.stl.r5.bu -side left\n",\ " \n",\ " \n",\ " checkbutton $f.stl.recalch -text \"STL - Recalc mesh size for surface optimization\" \\\n",\ " -variable stloptions.recalchopt\n",\ " pack $f.stl.recalch\n",\ "\n",\ " button $f.stl.calch -text \"Calc New H\" -command { redraw; Ng_STLCalcLocalH }\n",\ " pack $f.stl.calch\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ " set f [$w.nb subwidget chartopt]\n",\ "\n",\ "\n",\ " label $f.lab1 -text \"Yellow Edges Angle ()\"\n",\ " scale $f.scale1 -orient horizontal -length 300 \\\n",\ " -from 0 -to 90 -resolution 1 -tickinterval 10 \\\n",\ " -variable stloptions.yangle \n",\ "\n",\ " pack $f.lab1 $f.scale1\n",\ "\n",\ " label $f.lab2e -text \"Edge Corner Angle ()\"\n",\ " scale $f.scale2e -orient horizontal -length 360 -from 0 -to 180 \\\n",\ " -resolution 1 -tickinterval 20 \\\n",\ " -variable stloptions.edgecornerangle \n",\ " pack $f.lab2e $f.scale2e\n",\ " \n",\ " label $f.lab2 -text \"Chart Angle ()\"\n",\ " scale $f.scale2 -orient horizontal -length 360 -from 0 -to 180 \\\n",\ " -resolution 1 -tickinterval 20 \\\n",\ " -variable stloptions.chartangle \n",\ " pack $f.lab2 $f.scale2\n",\ " \n",\ " label $f.lab2b -text \"Outer Chart Angle ()\"\n",\ " scale $f.scale2b -orient horizontal -length 360 -from 0 -to 180 \\\n",\ " -resolution 1 -tickinterval 20 \\\n",\ " -variable stloptions.outerchartangle \n",\ " pack $f.lab2b $f.scale2b\n",\ "\n",\ "\n",\ "\n",\ "\n",\ " \n",\ " set f [$w.nb subwidget optimizer]\n",\ "\n",\ " \n",\ "\n",\ "\n",\ " tixControl $f.os2d -label \"Surface opt steps: \" -integer true \\\n",\ " -variable options.optsteps2d -min 0 -max 99 -step 1 \\\n",\ " -options {\n",\ " entry.width 3\n",\ " label.width 25\n",\ " label.anchor e\n",\ " } \n",\ "\n",\ " tixControl $f.os3d -label \"Volume opt steps: \" -integer true \\\n",\ " -variable options.optsteps3d -min 0 -max 99 -step 1 \\\n",\ " -options {\n",\ " entry.width 3\n",\ " label.width 25\n",\ " label.anchor e\n",\ " } \n",\ " \n",\ " tixControl $f.elw -label \"Element size weight: \" -integer false \\\n",\ " -variable options.elsizeweight -min 0 -max 1 -step 0.1 \\\n",\ " -options {\n",\ " entry.width 3\n",\ " label.width 25\n",\ " label.anchor e\n",\ " } \n",\ "\n",\ " tixControl $f.wem -label \"Worst element measure: \" -integer false \\\n",\ " -variable options.opterrpow -min 1 -max 10 -step 1 \\\n",\ " -options {\n",\ " entry.width 3\n",\ " label.width 25\n",\ " label.anchor e\n",\ " } \n",\ "\n",\ " pack $f.os2d $f.os3d $f.elw $f.wem\n",\ " \n",\ " frame $f.badellimit\n",\ " pack $f.badellimit -fill x\n",\ " label $f.badellimit.lab -text \"bad element criterion\";\n",\ " scale $f.badellimit.scale -orient horizontal -length 150 \\\n",\ " -from 160 -to 180 -resolution 1 \\\n",\ " -variable options.badellimit\n",\ " pack $f.badellimit.scale $f.badellimit.lab -side right -anchor s\n",\ "\n",\ "\n",\ " set f [$w.nb subwidget insider]\n",\ " \n",\ "\n",\ "\n",\ " checkbutton $f.localh -text \"Use Local Meshsize\" \\\n",\ " -variable options.localh\n",\ " checkbutton $f.delauney -text \"Use Delaunay\" \\\n",\ " -variable options.delaunay\n",\ " checkbutton $f.checkoverlap -text \"Check Overlapping\" \\\n",\ " -variable options.checkoverlap\n",\ " checkbutton $f.checkcb -text \"Check Chart Boundary\" \\\n",\ " -variable options.checkchartboundary\n",\ " checkbutton $f.blockfill -text \"Do Blockfilling\" \\\n",\ " -variable options.blockfill\n",\ "\n",\ " pack $f.localh $f.delauney $f.checkoverlap $f.blockfill $f.checkcb -anchor w\n",\ "\n",\ "\n",\ "\n",\ " \n",\ " set f [$w.nb subwidget debug]\n",\ "\n",\ " frame $f.cb\n",\ " pack $f.cb -side top\n",\ "\n",\ " \n",\ "\n",\ " checkbutton $f.cb.slowchecks -text \"Slow checks\" \\\n",\ " -variable debug.slowchecks -command { Ng_SetDebugParameters }\n",\ " checkbutton $f.cb.debugoutput -text \"Debugging outout\" \\\n",\ " -variable debug.debugoutput -command { Ng_SetDebugParameters }\n",\ " checkbutton $f.cb.haltexline -text \"Halt on exising line\" \\\n",\ " -variable debug.haltexistingline -command { Ng_SetDebugParameters }\n",\ " checkbutton $f.cb.haltoverlap -text \"Halt on Overlap\" \\\n",\ " -variable debug.haltoverlap -command { Ng_SetDebugParameters }\n",\ " checkbutton $f.cb.haltsuc -text \"Halt on success\" \\\n",\ " -variable debug.haltsuccess -command { Ng_SetDebugParameters }\n",\ " checkbutton $f.cb.haltnosuc -text \"Halt on no success\" \\\n",\ " -variable debug.haltnosuccess -command { Ng_SetDebugParameters }\n",\ " checkbutton $f.cb.haltlargequal -text \"Halt on large quality class\" \\\n",\ " -variable debug.haltlargequalclass -command { Ng_SetDebugParameters }\n",\ " checkbutton $f.cb.haltseg -text \"Halt on Segment:\" \\\n",\ " -variable debug.haltsegment -command { Ng_SetDebugParameters }\n",\ " checkbutton $f.cb.haltnode -text \"Halt on Node:\" \\\n",\ " -variable debug.haltnode -command { Ng_SetDebugParameters }\n",\ "\n",\ "\n",\ " 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 \n",\ "\n",\ " frame $f.cb.hf\n",\ " pack $f.cb.hf -pady 5\n",\ " checkbutton $f.cb.hf.cb -text \"Halt on Face:\" \\\n",\ " -variable debug.haltface -command { Ng_SetDebugParameters }\n",\ " entry $f.cb.hf.ent -textvariable debug.haltfacenr -width 5 \n",\ " pack $f.cb.hf.cb $f.cb.hf.ent -side left \n",\ "\n",\ " checkbutton $f.cb.showactivechart -text \"Show Active Meshing-Chart\" \\\n",\ " -variable stloptions.showactivechart -command { Ng_SetVisParameters; redraw }\n",\ "\n",\ "\n",\ "\n",\ "\n",\ " pack $f.cb.showactivechart\n",\ " \n",\ "\n",\ " frame $f.segs\n",\ " pack $f.segs -pady 5\n",\ " label $f.segs.lab1 -text \"P1:\";\n",\ " entry $f.segs.ent1 -width 8 -relief sunken \\\n",\ " -textvariable debug.haltsegmentp1 \n",\ " label $f.segs.lab2 -text \"P2:\";\n",\ " entry $f.segs.ent2 -width 8 -relief sunken \\\n",\ " -textvariable debug.haltsegmentp2 \n",\ " pack $f.segs.lab1 $f.segs.ent1 $f.segs.lab2 $f.segs.ent2 -side left\n",\ "\n",\ "\n",\ "\n",\ " frame $f.cont -relief groove -borderwidth 3\n",\ " pack $f.cont \n",\ " \n",\ " checkbutton $f.cont.multidrawing -text \"Draw Meshing\" \\\n",\ " -variable multithread_drawing \n",\ " pack $f.cont.multidrawing\n",\ " \n",\ " checkbutton $f.cont.multitestmode -text \"Meshing Testmode\" \\\n",\ " -variable multithread_testmode \n",\ " pack $f.cont.multitestmode\n",\ " \n",\ " button $f.cont.goon -text \"Go On\" -command { set multithread_pause 0 }\n",\ " pack $f.cont.multidrawing $f.cont.multitestmode $f.cont.goon -side left -expand yes\n",\ " \n",\ "\n",\ "\n",\ "\n",\ " global userlevel\n",\ " if { $userlevel < 3} {\n",\ " $w.nb delete insider\n",\ " $w.nb delete debug\n",\ " }\n",\ "\n",\ "\n",\ "\n",\ " \n",\ " \n",\ " \n",\ " \n",\ "\n",\ " \n",\ " frame $w.bu\n",\ " pack $w.bu -fill x -ipady 3\n",\ "\n",\ " button $w.bu.apl -text \"Apply\" -command { \n",\ " [.options_dlg.nb subwidget meshsize].meshsize invoke\n",\ " [.options_dlg.nb subwidget meshsize].grading invoke\n",\ " [.options_dlg.nb subwidget optimizer].os2d invoke\n",\ " [.options_dlg.nb subwidget optimizer].os3d invoke\n",\ " [.options_dlg.nb subwidget optimizer].elw invoke\n",\ " [.options_dlg.nb subwidget optimizer].wem invoke\n",\ "\n",\ " Ng_SetMeshingParameters \n",\ " Ng_SetDebugParameters\n",\ " }\n",\ "\n",\ " button $w.bu.ok -text \"Done\" -command {\n",\ " [.options_dlg.nb subwidget meshsize].meshsize invoke\n",\ " [.options_dlg.nb subwidget meshsize].grading invoke\n",\ " [.options_dlg.nb subwidget optimizer].os2d invoke\n",\ " [.options_dlg.nb subwidget optimizer].os3d invoke\n",\ " [.options_dlg.nb subwidget optimizer].elw invoke\n",\ " [.options_dlg.nb subwidget optimizer].wem invoke\n",\ "\n",\ " Ng_SetMeshingParameters\n",\ " Ng_SetDebugParameters\n",\ " wm withdraw .options_dlg\n",\ " }\n",\ "\n",\ " pack $w.bu.apl $w.bu.ok -side left -expand yes\n",\ " \n",\ " \n",\ " wm withdraw $w\n",\ " wm geom $w +100+100\n",\ " wm deiconify $w\n",\ " wm title $w \"Meshing Options\"\n",\ " focus .options_dlg\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "meshingoptionsdialog\n",\ "wm withdraw .options_dlg\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "proc geometryoptionsdialog { } {\n",\ "\n",\ "\n",\ " set w .geometry_dlg\n",\ " \n",\ " if {[winfo exists .geometry_dlg] == 1} {\n",\ " wm withdraw $w\n",\ " wm deiconify $w\n",\ " focus $w \n",\ " } {\n",\ "\n",\ " toplevel $w\n",\ " \n",\ " global geooptions\n",\ " \n",\ " Ng_GeometryOptions get\n",\ "\n",\ " checkbutton $w.drawcsg -text \"Draw Geometry\" \\\n",\ " -variable geooptions.drawcsg \n",\ " pack $w.drawcsg\n",\ "\n",\ " frame $w.fac\n",\ " pack $w.fac -pady 5\n",\ " label $w.fac.lab -text \"Facets:\";\n",\ " entry $w.fac.ent -width 8 -relief sunken \\\n",\ " -textvariable geooptions.facets\n",\ " pack $w.fac.lab $w.fac.ent -side left\n",\ " \n",\ " \n",\ " frame $w.det\n",\ " pack $w.det -pady 5\n",\ " label $w.det.lab -text \"Detail:\";\n",\ " entry $w.det.ent -width 8 -relief sunken \\\n",\ " -textvariable geooptions.detail\n",\ " pack $w.det.lab $w.det.ent -side left\n",\ " \n",\ " frame $w.cox\n",\ " pack $w.cox -pady 5\n",\ " label $w.cox.lab -text \"min/max x:\";\n",\ " entry $w.cox.ent1 -width 8 -relief sunken \\\n",\ " -textvariable geooptions.minx\n",\ " entry $w.cox.ent2 -width 8 -relief sunken \\\n",\ " -textvariable geooptions.maxx\n",\ " pack $w.cox.lab $w.cox.ent1 \\\n",\ " $w.cox.ent2 -side left\n",\ " \n",\ " frame $w.coy\n",\ " pack $w.coy -pady 5\n",\ " label $w.coy.lab -text \"min/max y:\";\n",\ " entry $w.coy.ent1 -width 8 -relief sunken \\\n",\ " -textvariable geooptions.miny\n",\ " entry $w.coy.ent2 -width 8 -relief sunken \\\n",\ " -textvariable geooptions.maxy\n",\ " pack $w.coy.lab $w.coy.ent1 \\\n",\ " $w.coy.ent2 -side left\n",\ " \n",\ " frame $w.coz\n",\ " pack $w.coz -pady 5\n",\ " label $w.coz.lab -text \"min/max z:\";\n",\ " entry $w.coz.ent1 -width 8 -relief sunken \\\n",\ " -textvariable geooptions.minz\n",\ " entry $w.coz.ent2 -width 8 -relief sunken \\\n",\ " -textvariable geooptions.maxz\n",\ " pack $w.coz.lab $w.coz.ent1 \\\n",\ " $w.coz.ent2 -side left\n",\ " \n",\ "\n",\ "\n",\ " \n",\ " \n",\ "\n",\ " frame $w.bu\n",\ " pack $w.bu -fill x -ipady 3\n",\ "\n",\ "\n",\ " button $w.bu.app -text \"Apply\" -command {\n",\ " Ng_GeometryOptions set\n",\ " }\n",\ " button $w.bu.ok -text \"Done\" -command {\n",\ " Ng_GeometryOptions set\n",\ " destroy .geometry_dlg\n",\ " }\n",\ " pack $w.bu.app $w.bu.ok -side left -expand yes\n",\ " \n",\ "\n",\ " wm withdraw $w\n",\ " wm geom $w +100+100\n",\ " wm deiconify $w\n",\ " wm title $w \"Geometry options\"\n",\ " focus $w\n",\ " }\n",\ "}\n",\ "\n",\ "proc viewingoptionsdialog { } {\n",\ "\n",\ " global userlevel\n",\ "\n",\ " set w .viewopts_dlg\n",\ " \n",\ " if {[winfo exists .viewopts_dlg] == 1} {\n",\ " wm withdraw $w\n",\ " wm deiconify $w\n",\ " focus $w \n",\ " } {\n",\ " toplevel $w\n",\ " \n",\ "\n",\ "\n",\ "\n",\ " tixNoteBook $w.nb -ipadx 6 -ipady 6\n",\ " \n",\ " $w.nb add general -label \"General\" -underline 0\n",\ " $w.nb add stl -label \"STL\" -underline 0\n",\ " $w.nb add occ -label \"IGES/STEP\" -underline 0\n",\ " $w.nb add mesh -label \"Mesh\" -underline 0\n",\ " $w.nb add light -label \"Light\" -underline 0\n",\ " $w.nb add edges -label \"Edges\" -underline 0\n",\ " $w.nb add misc -label \"Misc.\" -underline 3\n",\ "\n",\ "\n",\ " pack $w.nb -expand yes -fill both -padx 5 -pady 5 -side top \n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ " set f [$w.nb subwidget general]\n",\ "\n",\ " checkbutton $f.backcol -text \"White Background\" \\\n",\ " -variable viewoptions.whitebackground \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ "\n",\ " checkbutton $f.cross -text \"Draw Coordinate Cross\" \\\n",\ " -variable viewoptions.drawcoordinatecross \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ "\n",\ " checkbutton $f.color -text \"Draw Color-bar\" \\\n",\ " -variable viewoptions.drawcolorbar \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ "\n",\ " checkbutton $f.netgen -text \"Draw Netgen-logo\" \\\n",\ " -variable viewoptions.drawnetgenlogo \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ "\n",\ " pack $f.backcol $f.cross $f.color $f.netgen\n",\ "\n",\ "\n",\ " set f [$w.nb subwidget stl]\n",\ "\n",\ " frame $f.show -relief groove -borderwidth 3\n",\ " pack $f.show\n",\ " checkbutton $f.show.showtrias -text \"Show STL-Triangles\" \\\n",\ " -variable stloptions.showtrias -command { Ng_SetVisParameters; redraw }\n",\ " pack $f.show.showtrias -anchor w\n",\ " \n",\ " checkbutton $f.show.showfilledtrias -text \"Show Filled Triangles\" \\\n",\ " -variable stloptions.showfilledtrias -command { Ng_SetVisParameters; redraw }\n",\ " pack $f.show.showfilledtrias -anchor w\n",\ " \n",\ " checkbutton $f.show.showactivechart -text \"Show Active Meshing-Chart\" \\\n",\ " -variable stloptions.showactivechart -command { Ng_SetVisParameters; redraw }\n",\ " pack $f.show.showactivechart -anchor w\n",\ " \n",\ " checkbutton $f.show.showedges -text \"Show Edges\" \\\n",\ " -variable stloptions.showedges -command { Ng_SetVisParameters; redraw }\n",\ " pack $f.show.showedges -anchor w\n",\ " \n",\ " frame $f.special -relief groove -borderwidth 3\n",\ " pack $f.special\n",\ " checkbutton $f.special.showmarktrias -text \"Show Chart Triangles\" \\\n",\ " -variable stloptions.showmarktrias \\\n",\ " -command {set stldoctor.showfaces 0; Ng_STLDoctor; Ng_SetVisParameters; redraw }\n",\ " pack $f.special.showmarktrias -side left\n",\ "\n",\ " checkbutton $f.special.showfaces -text \"Show Faces\" \\\n",\ " -variable stldoctor.showfaces \\\n",\ " -command {set stloptions.showmarktrias 0; Ng_STLDoctor; Ng_SetVisParameters; redraw} \n",\ " pack $f.special.showfaces -side left\n",\ "\n",\ " frame $f.fn -relief groove -borderwidth 3\n",\ " pack $f.fn\n",\ " label $f.fn.lab3 -text \"Chart/Face number:\"\n",\ " scale $f.fn.scale3 -orient horizontal -length 200 -from 0 -to 200 \\\n",\ " -resolution 1 -tickinterval 50 \\\n",\ " -command { Ng_SetVisParameters; redraw } -variable stloptions.chartnumber \n",\ " pack $f.fn.lab3 $f.fn.scale3 -side left\n",\ " \n",\ " frame $f.fo -relief groove -borderwidth 3\n",\ " pack $f.fo\n",\ " label $f.fo.lab -text \"Chart/Face Offset:\";\n",\ " entry $f.fo.ent -width 5 -relief sunken \\\n",\ " -textvariable stloptions.chartnumberoffset\n",\ " pack $f.fo.lab $f.fo.ent -side left\n",\ "\n",\ " frame $f.mt\n",\ " pack $f.mt -fill x\n",\ " checkbutton $f.mt.bu -text \"Show Marked (Dirty) Triangles\" \\\n",\ " -variable stldoctor.showmarkedtrigs \\\n",\ " -command {Ng_STLDoctor; redraw} \n",\ " pack $f.mt.bu\n",\ "\n",\ " frame $f.ep\n",\ " pack $f.ep -fill x\n",\ " checkbutton $f.ep.bu -text \"show edge corner points\" \\\n",\ " -variable stldoctor.showedgecornerpoints \\\n",\ " -command {Ng_STLDoctor; redraw} \n",\ " pack $f.ep.bu\n",\ "\n",\ " frame $f.stt\n",\ " pack $f.stt -fill x\n",\ " checkbutton $f.stt.bu -text \"show touched triangle chart\" \\\n",\ " -variable stldoctor.showtouchedtrigchart \\\n",\ " -command {set stldoctor.showfaces 0; set stloptions.showmarktrias 1; \\\n",\ " Ng_STLDoctor; Ng_SetVisParameters; redraw} \n",\ " pack $f.stt.bu\n",\ "\n",\ " frame $f.sml\n",\ " pack $f.sml -fill x\n",\ " checkbutton $f.sml.bu -text \"draw meshed edges\" \\\n",\ " -variable stldoctor.drawmeshededges \\\n",\ " -command {Ng_STLDoctor;} \n",\ " pack $f.sml.bu\n",\ " \n",\ " \n",\ " frame $f.sm\n",\ " pack $f.sm -fill x\n",\ " checkbutton $f.sm.bu -text \"select with mouse\" \\\n",\ " -variable stldoctor.selectwithmouse\n",\ " pack $f.sm.bu\n",\ " \n",\ " frame $f.st -relief groove -borderwidth 3\n",\ " pack $f.st -fill x\n",\ " label $f.st.lab -text \"Select triangle by number\";\n",\ " entry $f.st.ent -width 5 -relief sunken \\\n",\ " -textvariable stldoctor.selecttrig\n",\ " pack $f.st.ent $f.st.lab -side left -expand yes\n",\ " \n",\ " frame $f.vc -relief groove -borderwidth 3\n",\ " pack $f.vc -fill x\n",\ " checkbutton $f.vc.bu -text \"show vicinity\" \\\n",\ " -variable stldoctor.showvicinity \\\n",\ " -command {Ng_STLDoctor vicinity; redraw}\n",\ " label $f.vc.lab -text \"vicinity size\";\n",\ " scale $f.vc.sc -orient horizontal -length 200 -from 0 -to 200 \\\n",\ " -resolution 1 -variable stldoctor.vicinity \\\n",\ " -command { Ng_STLDoctor vicinity; redraw }\n",\ " pack $f.vc.bu $f.vc.lab $f.vc.sc -expand yes\n",\ " \n",\ "\n",\ "\n",\ " set f [$w.nb subwidget occ]\n",\ " \n",\ " checkbutton $f.occshowsurfaces -text \"Show surfaces \" \\\n",\ " -variable occoptions.showsurfaces \\\n",\ " -command { Ng_SetOCCVisParameters; redraw }\n",\ "\n",\ " checkbutton $f.occshowedges -text \"Show edges \" \\\n",\ " -variable occoptions.showedges \\\n",\ " -command { Ng_SetOCCVisParameters; redraw }\n",\ "\n",\ " frame $f.deflection -relief groove -borderwidth 3\n",\ " pack $f.deflection -fill x\n",\ " button $f.deflection.lab -text \"Rebuild visualization data\" \\\n",\ " -command {\n",\ " Ng_SetOCCVisParameters\n",\ " Ng_OCCCommand buildvisualizationmesh\n",\ " redraw\n",\ " }\n",\ "\n",\ " tixControl $f.deflection.ent -label \"Visualization smoothness\" -integer false \\\n",\ " -variable occoptions.deflection -min 0.1 -max 3 -step 0.1 \\\n",\ " -options { entry.width 3 } \\\n",\ " -command { Ng_SetOCCVisParameters }\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ " pack $f.deflection.ent $f.deflection.lab -side left -expand yes\n",\ " pack $f.occshowsurfaces $f.occshowedges\n",\ "\n",\ "\n",\ " \n",\ " tixControl $f.showsolid -label \"Show solid (0 for all)\" -integer true \\\n",\ " -variable occoptions.showsolidnr -min 0 -max 999 \\\n",\ " -options { entry.width 3 } \\\n",\ " -command { Ng_SetOCCVisParameters; redraw }\n",\ " \n",\ " tixControl $f.showsolid2 -label \"Show solid 2\" -integer true \\\n",\ " -variable occoptions.showsolidnr2 -min 0 -max 999 \\\n",\ " -options { entry.width 3 } \\\n",\ " -command { Ng_SetOCCVisParameters; redraw }\n",\ "\n",\ " button $f.subtract -text \"Subtract (2 minus 1)\" \\\n",\ " -command {\n",\ " Ng_ACISCommand subtract ${occoptions.showsolidnr} ${occoptions.showsolidnr2}\n",\ " redraw\n",\ " }\n",\ "\n",\ " button $f.combine -text \"Combine all\" \\\n",\ " -command {\n",\ " Ng_ACISCommand combineall\n",\ " redraw\n",\ " }\n",\ "\n",\ " pack $f.showsolid $f.showsolid2 $f.subtract $f.combine\n",\ "\n",\ "\n",\ "\n",\ "\n",\ " set f [$w.nb subwidget mesh]\n",\ "\n",\ " checkbutton $f.showcolor -text \"Colored Meshsize Visualization\" \\\n",\ " -variable viewoptions.colormeshsize \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ "\n",\ "\n",\ " checkbutton $f.showfilledtrigs -text \"Show filled triangles\" \\\n",\ " -variable viewoptions.drawfilledtrigs \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ " \n",\ " checkbutton $f.showedges -text \"Show edges\" \\\n",\ " -variable viewoptions.drawedges \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ " \n",\ "\n",\ " checkbutton $f.showoutline -text \"Show Triangle Outline\" \\\n",\ " -variable viewoptions.drawoutline \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ "\n",\ " \n",\ " tixControl $f.subdiv -label \"Subdivision\" -integer true \\\n",\ " -variable visoptions.subdivisions -min 0 -max 8 \\\n",\ " -options { entry.width 2 } \\\n",\ " -command { puts \"mesh-subdivision\"; Ng_SetVisParameters; Ng_Vis_Set parameters; Ng_SetNextTimeStamp; redraw }\n",\ " \n",\ " \n",\ " checkbutton $f.showbadels -text \"Show bad elements\" \\\n",\ " -variable viewoptions.drawbadels \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ "\n",\ "\n",\ "\n",\ " checkbutton $f.showprisms -text \"Show prisms\" \\\n",\ " -variable viewoptions.drawprisms \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ "\n",\ " checkbutton $f.showpyramids -text \"Show pyramids\" \\\n",\ " -variable viewoptions.drawpyramids \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ "\n",\ " checkbutton $f.showhexes -text \"Show hexes\" \\\n",\ " -variable viewoptions.drawhexes \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ "\n",\ " frame $f.fshrink\n",\ " label $f.fshrink.lab -text \"Shrink elements\"\n",\ " scale $f.fshrink.scale -orient horizontal -length 200 -from 0 -to 1.0001 \\\n",\ " -resolution 0.01 -tickinterval 0.25 \\\n",\ " -command { Ng_SetVisParameters; redraw } -variable viewoptions.shrink\n",\ "\n",\ "\n",\ " checkbutton $f.showidentified -text \"Show identified points\" \\\n",\ " -variable viewoptions.drawidentified \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ "\n",\ " checkbutton $f.showmetispartition -text \"Show METIS Partition\" \\\n",\ " -variable viewoptions.drawmetispartition \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ "\n",\ " checkbutton $f.showpointnumbers -text \"Show Point-numbers\" \\\n",\ " -variable viewoptions.drawpointnumbers \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ " checkbutton $f.showedgenumbers -text \"Show Edge-numbers\" \\\n",\ " -variable viewoptions.drawedgenumbers \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ " checkbutton $f.showfacenumbers -text \"Show Face-numbers\" \\\n",\ " -variable viewoptions.drawfacenumbers \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ " checkbutton $f.showelementnumbers -text \"Show Element-numbers\" \\\n",\ " -variable viewoptions.drawelementnumbers \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ " \n",\ " \n",\ " tixControl $f.showdomain -label \"Show surface of domain\" -integer true \\\n",\ " -variable viewoptions.drawdomainsurf -min 0 -max 50 \\\n",\ " -options { entry.width 2 } \\\n",\ " -command { Ng_SetVisParameters; Ng_Vis_Set parameters; redraw }\n",\ " \n",\ " \n",\ " \n",\ "\n",\ " frame $f.center -relief groove -borderwidth 3\n",\ " pack $f.center -fill x\n",\ " button $f.center.lab -text \"Set Center Point\" \\\n",\ " -command { Ng_SetVisParameters; Ng_Center; redraw }\n",\ " entry $f.center.ent -width 5 -relief sunken \\\n",\ " -textvariable viewoptions.centerpoint \n",\ " pack $f.center.ent $f.center.lab -side left -expand yes\n",\ " \n",\ " frame $f.drawel -relief groove -borderwidth 3\n",\ " pack $f.drawel -fill x\n",\ " button $f.drawel.lab -text \"Draw Element\" \\\n",\ " -command { Ng_SetVisParameters; Ng_ZoomAll; redraw }\n",\ " entry $f.drawel.ent -width 5 -relief sunken \\\n",\ " -textvariable viewoptions.drawelement \n",\ " pack $f.drawel.ent $f.drawel.lab -side left -expand yes\n",\ "\n",\ " pack $f.showfilledtrigs\n",\ " pack $f.showoutline $f.subdiv $f.showedges $f.showbadels \n",\ " pack $f.showdomain \n",\ " pack $f.showpointnumbers \n",\ " pack $f.showedgenumbers $f.showfacenumbers $f.showelementnumbers \n",\ " pack $f.showmetispartition\n",\ "\n",\ "\n",\ " frame $f.frametets\n",\ " checkbutton $f.frametets.showtets -text \"Show Tets in domain \" \\\n",\ " -variable viewoptions.drawtets \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ " tixControl $f.frametets.showtetsdomain -label \"\" -integer true \\\n",\ " -variable viewoptions.drawtetsdomain -min 0 -max 500 \\\n",\ " -options { entry.width 2 } \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ "\n",\ " pack $f.frametets\n",\ " pack $f.frametets.showtets $f.frametets.showtetsdomain -side left\n",\ "\n",\ "\n",\ " pack $f.showcolor $f.showpyramids $f.showprisms $f.showhexes $f.showidentified\n",\ " \n",\ " pack $f.fshrink \n",\ " pack $f.fshrink.lab $f.fshrink.scale -side left\n",\ " \n",\ " \n",\ " \n",\ " \n",\ "\n",\ "\n",\ "\n",\ "\n",\ " set f [$w.nb subwidget light]\n",\ " \n",\ " label $f.lab1 -text \"Ambient Light\"\n",\ " scale $f.scale1 -orient horizontal -length 300 -from 0 -to 1 \\\n",\ " -resolution 0.01 -tickinterval 0.2 \\\n",\ " -command { Ng_SetVisParameters; redraw } -variable viewoptions.light.amb \n",\ " label $f.lab2 -text \"Diffuse Light\"\n",\ " scale $f.scale2 -orient horizontal -length 300 -from 0 -to 1 \\\n",\ " -resolution 0.01 -tickinterval 0.2 \\\n",\ " -command { Ng_SetVisParameters; redraw } -variable viewoptions.light.diff \n",\ " label $f.lab3 -text \"Specular Light\"\n",\ " scale $f.scale3 -orient horizontal -length 300 -from 0 -to 1 \\\n",\ " -resolution 0.01 -tickinterval 0.2 \\\n",\ " -command { Ng_SetVisParameters; redraw } -variable viewoptions.light.spec \n",\ " label $f.lab4 -text \"Material Shininess\"\n",\ " scale $f.scale4 -orient horizontal -length 300 -from 0 -to 128 \\\n",\ " -resolution 1 -tickinterval 32 \\\n",\ " -command { Ng_SetVisParameters; redraw } -variable viewoptions.mat.shininess \n",\ " label $f.lab5 -text \"Material Transparency\"\n",\ " scale $f.scale5 -orient horizontal -length 300 -from 0 -to 1 \\\n",\ " -resolution 0.01 -tickinterval 0.2 \\\n",\ " -command { Ng_SetVisParameters; redraw } -variable viewoptions.mat.transp \n",\ " \n",\ " pack $f.lab1 $f.scale1 $f.lab2 $f.scale2 $f.lab3 $f.scale3 $f.lab4 $f.scale4 $f.lab5 $f.scale5\n",\ " \n",\ "\n",\ "\n",\ "\n",\ "\n",\ " set f [$w.nb subwidget edges]\n",\ "\n",\ " checkbutton $f.showedges -text \"Show Edges\" \\\n",\ " -variable viewoptions.drawededges \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ " checkbutton $f.showpoints -text \"Show Points\" \\\n",\ " -variable viewoptions.drawedpoints \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ " checkbutton $f.showpointnrs -text \"Show Points Nrs\" \\\n",\ " -variable viewoptions.drawedpointnrs \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ " checkbutton $f.showtang -text \"Show CP Tangents\" \\\n",\ " -variable viewoptions.drawedtangents \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ " checkbutton $f.drawedgenrs -text \"Show Edge Nrs\" \\\n",\ " -variable viewoptions.drawededgenrs \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ " \n",\ " pack $f.showedges $f.showpoints $f.showpointnrs $f.showtang $f.drawedgenrs\n",\ "\n",\ " frame $f.center -relief groove -borderwidth 3\n",\ " pack $f.center -fill x\n",\ " button $f.center.lab -text \"Set Center Point\" \\\n",\ " -command { Ng_SetVisParameters; Ng_Center; redraw }\n",\ " entry $f.center.ent -width 5 -relief sunken \\\n",\ " -textvariable viewoptions.centerpoint \n",\ " pack $f.center.ent $f.center.lab -side left -expand yes\n",\ " \n",\ "\n",\ "\n",\ " frame $f.f1\n",\ " pack $f.f1 -pady 5\n",\ " label $f.f1.lab -text \"SpecPoint Veclen\"\n",\ " entry $f.f1.ent -width 5 -relief sunken -textvariable viewoptions.specpointvlen\n",\ " pack $f.f1.lab $f.f1.ent\n",\ " \n",\ "\n",\ "\n",\ "\n",\ " set f [$w.nb subwidget misc]\n",\ "\n",\ " frame $f.point -relief groove -borderwidth 3\n",\ "\n",\ " frame $f.point.dp\n",\ " \n",\ " checkbutton $f.point.dp.drawpoint -text \"Draw Point\" \\\n",\ " -variable viewoptions.drawspecpoint \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ "\n",\ " entry $f.point.dp.px -width 8 -relief sunken -textvariable viewoptions.specpointx\n",\ " entry $f.point.dp.py -width 8 -relief sunken -textvariable viewoptions.specpointy\n",\ " entry $f.point.dp.pz -width 8 -relief sunken -textvariable viewoptions.specpointz\n",\ "\n",\ " pack $f.point.dp.drawpoint $f.point.dp.px $f.point.dp.py $f.point.dp.pz -side left\n",\ "\n",\ " pack $f.point.dp\n",\ "\n",\ " checkbutton $f.point.center -text \"Use as Center\" \\\n",\ " -variable viewoptions.usecentercoords \\\n",\ " -command { \n",\ " if { ${viewoptions.usecentercoords} } {\n",\ " set viewoptions.centerx ${viewoptions.specpointx}\n",\ " set viewoptions.centery ${viewoptions.specpointy}\n",\ " set viewoptions.centerz ${viewoptions.specpointz}\n",\ " Ng_SetVisParameters; Ng_Center\n",\ " redraw\n",\ " } {\n",\ " Ng_SetVisParameters\n",\ " }\n",\ " \n",\ " \n",\ " }\n",\ "\n",\ " pack $f.point.center\n",\ " \n",\ " pack $f.point -fill x -ipady 3\n",\ "\n",\ "\n",\ " \n",\ " frame $w.bu\n",\ " pack $w.bu -fill x -ipady 3\n",\ "\n",\ "\n",\ " button $w.bu.done -text \"Done\" -command {\n",\ " Ng_SetVisParameters;\n",\ " redraw\n",\ " destroy .viewopts_dlg\n",\ " }\n",\ " button $w.bu.apply -text \"Apply\" -command {\n",\ " Ng_SetVisParameters;\n",\ " redraw\n",\ " }\n",\ " pack $w.bu.apply $w.bu.done -expand yes -side left\n",\ " \n",\ " wm withdraw $w\n",\ " wm geom $w +100+100\n",\ " wm deiconify $w\n",\ " wm title $w \"Viewing options\"\n",\ " focus $w\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "set clippingdialog_pop1 0\n",\ "set clippingdialog_pop2 0\n",\ "set clippingdialog_pop3 0\n",\ "set clippingdialog_pop4 0\n",\ "\n",\ "\n",\ "proc clippingdialog { } {\n",\ "\n",\ " global clippingdialog_pop1\n",\ " global clippingdialog_pop2\n",\ " global clippingdialog_pop3\n",\ " global clippingdialog_pop4\n",\ " set clippingdialog_pop1 1\n",\ " set clippingdialog_pop2 1\n",\ " set clippingdialog_pop3 1\n",\ " set clippingdialog_pop4 1\n",\ " \n",\ " set w .clipping_dlg\n",\ " \n",\ " if {[winfo exists .clipping_dlg] == 1} {\n",\ " wm withdraw $w\n",\ " wm deiconify $w\n",\ " focus $w \n",\ " } {\n",\ "\n",\ " toplevel $w\n",\ "\n",\ " label $w.lab1 -text \"Normal x\"\n",\ " scale $w.scale1 -orient horizontal -length 300 -from -1 -to 1 \\\n",\ " -resolution 0.01 -tickinterval 0.5 \\\n",\ " -variable viewoptions.clipping.nx \\\n",\ " -command { popupcheckredraw2 clippingdialog_pop1 ${viewoptions.clipping.enable} }\n",\ "\n",\ " \n",\ " label $w.lab2 -text \"Normal y\"\n",\ " scale $w.scale2 -orient horizontal -length 300 -from -1 -to 1 \\\n",\ " -resolution 0.01 -tickinterval 0.5 \\\n",\ " -variable viewoptions.clipping.ny \\\n",\ " -command { popupcheckredraw2 clippingdialog_pop2 ${viewoptions.clipping.enable} }\n",\ "\n",\ " label $w.lab3 -text \"Normal z\"\n",\ " scale $w.scale3 -orient horizontal -length 300 -from -1 -to 1 \\\n",\ " -resolution 0.01 -tickinterval 0.5 \\\n",\ " -variable viewoptions.clipping.nz \\\n",\ " -command { popupcheckredraw2 clippingdialog_pop3 ${viewoptions.clipping.enable} }\n",\ " label $w.lab4 -text \"Distance\"\n",\ " scale $w.scale4 -orient horizontal -length 300 -from -1 -to 1.001 \\\n",\ " -resolution 0.0001 -tickinterval 0.5 \\\n",\ " -variable viewoptions.clipping.dist \\\n",\ " -command { popupcheckredraw2 clippingdialog_pop4 ${viewoptions.clipping.enable} }\n",\ " \n",\ " \n",\ " tixControl $w.clipdomain -label \"Clip only domain\" -integer true \\\n",\ " -variable viewoptions.clipping.onlydomain -min 0 -max 50 \\\n",\ " -options { entry.width 2 } \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ " tixControl $w.donotclipdomain -label \"Do not clip domain\" -integer true \\\n",\ " -variable viewoptions.clipping.notdomain -min 0 -max 50 \\\n",\ " -options { entry.width 2 } \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ "\n",\ " pack $w.lab1 $w.scale1 $w.lab2 $w.scale2 $w.lab3 $w.scale3 $w.lab4 $w.scale4 $w.clipdomain $w.donotclipdomain\n",\ "\n",\ " \n",\ " checkbutton $w.cb1 -text \"Enable clipping\" \\\n",\ " -variable viewoptions.clipping.enable \\\n",\ " -command { Ng_SetVisParameters; redraw } \n",\ " \n",\ " pack $w.cb1\n",\ " \n",\ "\n",\ " \n",\ " frame $w.bu\n",\ " pack $w.bu -fill x -ipady 3\n",\ "\n",\ " button $w.bu.cancle -text \"Done\" -command \"destroy $w\"\n",\ " pack $w.bu.cancle -expand yes\n",\ " \n",\ " \n",\ " wm withdraw $w\n",\ " wm geom $w +100+100\n",\ " wm deiconify $w\n",\ " wm title $w \"Clipping Plane\"\n",\ " focus $w\n",\ "\n",\ "\n",\ "\n",\ "\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "proc refinementdialog { } {\n",\ "\n",\ " set w .refinement_dlg\n",\ " \n",\ " if {[winfo exists .refinement_dlg] == 1} {\n",\ " wm withdraw $w\n",\ " wm deiconify $w\n",\ " focus $w \n",\ " } {\n",\ "\n",\ " toplevel $w\n",\ "\n",\ " \n",\ " tixControl $w.meshsize -label \"max mesh-size: \" -integer false \\\n",\ " -variable options.meshsize -min 1e-6 -max 1e6 \\\n",\ " -options {\n",\ " entry.width 6\n",\ " label.width 25\n",\ " label.anchor e\n",\ " } \n",\ "\n",\ " pack $w.meshsize\n",\ "\n",\ " global localh\n",\ " set localh 1\n",\ " tixControl $w.loch -label \"local mesh-size: \" -integer false \\\n",\ " -variable localh -min 1e-6 -max 1e6 \\\n",\ " -options {\n",\ " entry.width 6\n",\ " label.width 25\n",\ " label.anchor e\n",\ " } \n",\ " \n",\ " pack $w.loch\n",\ " \n",\ " \n",\ " button $w.restface -text \"Restrict H at face\" \\\n",\ " -command {\n",\ " .refinement_dlg.meshsize invoke\n",\ " .refinement_dlg.loch invoke\n",\ " Ng_RestrictH face $localh\n",\ " }\n",\ " button $w.restedge -text \"Restrict H at edge\" \\\n",\ " -command {\n",\ " .refinement_dlg.meshsize invoke\n",\ " .refinement_dlg.loch invoke\n",\ " Ng_RestrictH edge $localh\n",\ " }\n",\ " button $w.restelement -text \"Restrict H at element\" \\\n",\ " -command {\n",\ " .refinement_dlg.meshsize invoke\n",\ " .refinement_dlg.loch invoke\n",\ " Ng_RestrictH element $localh\n",\ " }\n",\ " button $w.restpoint -text \"Restrict H at point\" \\\n",\ " -command {\n",\ " .refinement_dlg.meshsize invoke\n",\ " .refinement_dlg.loch invoke\n",\ " Ng_RestrictH point $localh\n",\ " }\n",\ "\n",\ "\n",\ " pack $w.restface $w.restedge $w.restelement $w.restpoint\n",\ "\n",\ "\n",\ "\n",\ " button $w.anisoedge -text \"Declare Anisotropic edge\" \\\n",\ " -command {\n",\ " Ng_Anisotropy edge \n",\ " }\n",\ " pack $w.anisoedge\n",\ " \n",\ "\n",\ " frame $w.bu\n",\ " pack $w.bu -fill x -ipady 3\n",\ "\n",\ "\n",\ " button $w.bu.cancle -text \"Done\" -command \"destroy .refinement_dlg\"\n",\ " button $w.bu.refine -text \"Refine\" \\\n",\ " -command { \n",\ " set oldnp 0; set newnp $status_np; \n",\ " while { $oldnp < $newnp } {\n",\ " set level [expr $level+1]\n",\ " Ng_Bisect; \n",\ " Ng_HighOrder ${options.elementorder}\n",\ " Ng_ReadStatus;\n",\ " redraw; \n",\ " set oldnp $newnp\n",\ " set newnp $status_np\n",\ " puts \"oldnp $oldnp newnp $newnp\"\n",\ " }\n",\ " } \n",\ " button $w.bu.zrefine -text \"Z-Refine\" \\\n",\ " -command { Ng_ZRefinement; Ng_ReadStatus; redraw; }\n",\ " \n",\ " pack $w.bu.zrefine $w.bu.refine $w.bu.cancle -expand yes -side left\n",\ " \n",\ " wm withdraw $w\n",\ " wm geom $w +100+100\n",\ " wm deiconify $w\n",\ " wm title $w \"Select Refinement\"\n",\ " focus $w\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "proc bcpropdialog { } {\n",\ "\n",\ " set w .bcprop_dlg\n",\ " \n",\ " if {[winfo exists .bcprop_dlg] == 1} {\n",\ " wm withdraw $w\n",\ " wm deiconify $w\n",\ " } {\n",\ " toplevel $w\n",\ " \n",\ " frame $w.face -borderwidth 3\n",\ " pack $w.face -fill x\n",\ " label $w.face.lab -text \"face index:\"\n",\ " label $w.face.ent -text 1 -padx 4\n",\ " button $w.face.next -text \"next\" -command {\n",\ " set w .bcprop_dlg; \n",\ " set facenr [$w.face.ent cget -text]\n",\ " if {$facenr == [Ng_BCProp getnfd]} {\n",\ " set facenr 1 \n",\ " } {\n",\ " set facenr [expr $facenr + 1]\n",\ " }\n",\ " $w.face.ent configure -text $facenr\n",\ " Ng_BCProp setactive $facenr\n",\ " set bcnr [Ng_BCProp getbc $facenr]\n",\ " $w.bc.ent delete 0 end\n",\ " $w.bc.ent insert 0 $bcnr\n",\ "\n",\ " redraw\n",\ " } \n",\ " button $w.face.prev -text \"prev\" -command {\n",\ " set w .bcprop_dlg; \n",\ " set facenr [$w.face.ent cget -text]\n",\ " if {$facenr == 1} {\n",\ " set facenr [Ng_BCProp getnfd]\n",\ " } {\n",\ " set facenr [expr $facenr - 1]\n",\ " }\n",\ " $w.face.ent configure -text $facenr\n",\ " Ng_BCProp setactive $facenr\n",\ " set bcnr [Ng_BCProp getbc $facenr]\n",\ " $w.bc.ent delete 0 end\n",\ " $w.bc.ent insert 0 $bcnr\n",\ "\n",\ " redraw\n",\ " } \n",\ " \n",\ " \n",\ " pack $w.face.lab $w.face.ent $w.face.prev $w.face.next -side left \n",\ " \n",\ " frame $w.bc -borderwidth 3\n",\ " pack $w.bc -fill x\n",\ " label $w.bc.lab -text \"bc property:\"\n",\ " entry $w.bc.ent -width 5 -relief sunken \n",\ " button $w.bc.but -text \"change\" -command { \n",\ " set w .bcprop_dlg; \n",\ " Ng_BCProp setbc [$w.face.ent cget -text] [$w.bc.ent get]; \n",\ " }\n",\ " button $w.bc.but2 -text \"all\" -command { \n",\ " set w .bcprop_dlg; \n",\ " Ng_BCProp setall [$w.bc.ent get]; \n",\ " }\n",\ " pack $w.bc.lab $w.bc.ent $w.bc.but $w.bc.but2 -side left -expand yes\n",\ "\n",\ " frame $w.bcname -borderwidth 3\n",\ " pack $w.bcname -fill x\n",\ " label $w.bcname.lab -text \"bc name:\"\n",\ " label $w.bcname.ent -text \"-\"\n",\ " pack $w.bcname.lab $w.bcname.ent -side left -expand yes\n",\ " \n",\ "\n",\ " frame $w.bu\n",\ " pack $w.bu -fill x -ipady 3\n",\ "\n",\ " button $w.bu.close -text \"Close\" -command { destroy .bcprop_dlg }\n",\ "\n",\ " pack $w.bu.close -expand yes -side left\n",\ " \n",\ " wm withdraw $w\n",\ " wm geom $w +100+100\n",\ " wm deiconify $w\n",\ " wm title $w \"Boundary Conditions\"\n",\ " }\n",\ "\n",\ " focus $w \n",\ "\n",\ " set facenr [Ng_BCProp getactive]\n",\ " $w.face.ent configure -text $facenr\n",\ " \n",\ " set bcnr [Ng_BCProp getbc $facenr]\n",\ " $w.bc.ent delete 0 end\n",\ " $w.bc.ent insert 0 $bcnr\n",\ "\n",\ " set bcname [Ng_BCProp getbcname $facenr]\n",\ " $w.bcname.ent configure -text $bcname\n",\ "\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "proc METISdialog { } {\n",\ "\n",\ " set w .metis_dlg\n",\ " set w.parts 64\n",\ " \n",\ " if {[winfo exists .metis_dlg] == 1} {\n",\ " wm withdraw $w\n",\ " wm deiconify $w\n",\ " } {\n",\ " toplevel $w\n",\ " \n",\ " frame $w.a -borderwidth 0\n",\ " frame $w.b -borderwidth 0\n",\ " pack $w.a $w.b\n",\ "\n",\ " label $w.a.lab -text \"Number of partitions:\"\n",\ " entry $w.a.ent -textvariable w.parts -width 4 -relief sunken\n",\ "\n",\ " button $w.b.start -text \"Start METIS\" -command { \n",\ " Ng_Metis ${w.parts}\n",\ " redraw\n",\ " }\n",\ " button $w.b.cancel -text \"Cancel\" -command { destroy .metis_dlg }\n",\ " pack $w.a.lab $w.a.ent -side left -expand yes\n",\ " pack $w.b.start $w.b.cancel -side left\n",\ "\n",\ "\n",\ " wm withdraw $w\n",\ " wm geom $w +100+100\n",\ " wm deiconify $w\n",\ " wm title $w \"METIS Partitioning\"\n",\ " focus $w\n",\ " \n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "proc stloptionsdialog { } {\n",\ "\n",\ " set w .stlopts_dlg\n",\ " \n",\ " if {[winfo exists .stlopts_dlg] == 1} {\n",\ " wm withdraw $w\n",\ " wm deiconify $w\n",\ " focus $w \n",\ " } {\n",\ " toplevel $w\n",\ "\n",\ " tixNoteBook $w.nb -ipadx 6 -ipady 6\n",\ " \n",\ " \n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ " \n",\ " \n",\ " \n",\ " \n",\ "\n",\ " \n",\ " \n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ " frame $w.bu\n",\ " pack $w.bu -fill x -ipady 3\n",\ "\n",\ "\n",\ " button $w.bu.apply -text \"Apply\" -command { redraw; Ng_GenerateMesh 1 2}\n",\ " button $w.bu.cancle -text \"Done\" -command { destroy .stlopts_dlg }\n",\ " pack $w.bu.cancle $w.bu.apply -side left -expand yes\n",\ " \n",\ "\n",\ " wm withdraw $w\n",\ " wm geom $w +100+100\n",\ " wm deiconify $w\n",\ " wm title $w \"STL Options\"\n",\ " focus $w\n",\ " }\n",\ "}\n",\ "\n",\ "proc stldoctordialog { } {\n",\ "\n",\ " set wd .stldoctor_dlg\n",\ "\n",\ " if {[winfo exists .stldoctor_dlg] == 1} {\n",\ " wm withdraw $wd\n",\ " wm deiconify $wd\n",\ " focus $wd \n",\ " } {\n",\ " \n",\ " toplevel $wd\n",\ "\n",\ " tixNoteBook $wd.nb -ipadx 6 -ipady 6\n",\ " \n",\ " $wd.nb add general -label \"General\" -underline 0\n",\ " $wd.nb add topology -label \"Edit Topology\" -underline 5\n",\ " $wd.nb add edges -label \"Edit Edges\" -underline 5\n",\ " $wd.nb add normals -label \"Edit Normals\" -underline 5\n",\ " $wd.nb add advanced -label \"Advanced\" -underline 0\n",\ "\n",\ "\n",\ " pack $wd.nb -expand yes -fill both -padx 5 -pady 5 -side top \n",\ "\n",\ "\n",\ " \n",\ " set f [$wd.nb subwidget general]\n",\ "\n",\ "\n",\ " frame $f.show\n",\ " pack $f.show -fill x\n",\ " checkbutton $f.show.showtrias -text \"Show STL-Triangles\" \\\n",\ " -variable stloptions.showtrias -command { Ng_SetVisParameters; redraw }\n",\ " pack $f.show.showtrias -anchor w\n",\ " \n",\ " checkbutton $f.show.showfilledtrias -text \"Show Filled Triangles\" \\\n",\ " -variable stloptions.showfilledtrias -command { Ng_SetVisParameters; redraw }\n",\ " pack $f.show.showfilledtrias -anchor w\n",\ "\n",\ " set selmodevals { 0 1 2 3 4 }\n",\ " set selmodelabs(0) \"triangle\" \n",\ " set selmodelabs(1) \"edge\" \n",\ " set selmodelabs(2) \"point\" \n",\ " set selmodelabs(3) \"line\" \n",\ " set selmodelabs(4) \"line cluster\" \n",\ "\n",\ " tixOptionMenu $f.selmode -label \"Double Click selects :\" \\\n",\ " -options {\n",\ " label.width 19\n",\ " label.anchor e\n",\ " menubutton.width 15\n",\ " } \n",\ "\n",\ " foreach selmodev $selmodevals {\n",\ " $f.selmode add command $selmodev -label $selmodelabs($selmodev)\n",\ " }\n",\ " $f.selmode config -variable stldoctor.selectmode\n",\ " $f.selmode config -command { Ng_STLDoctor }\n",\ " global stldoctor.selectmode\n",\ " pack $f.selmode\n",\ "\n",\ " frame $f.sm\n",\ " pack $f.sm -fill x\n",\ " checkbutton $f.sm.bu -text \"select with mouse\" \\\n",\ " -variable stldoctor.selectwithmouse\n",\ " pack $f.sm.bu \n",\ "\n",\ " frame $f.st -relief groove -borderwidth 3\n",\ " pack $f.st -fill x\n",\ " label $f.st.lab -text \"Select triangle by number\";\n",\ " entry $f.st.ent -width 5 -relief sunken \\\n",\ " -textvariable stldoctor.selecttrig\n",\ " pack $f.st.ent $f.st.lab -side left -expand yes\n",\ "\n",\ " frame $f.vc -relief groove -borderwidth 3\n",\ " pack $f.vc -fill x\n",\ " checkbutton $f.vc.bu -text \"show vicinity\" \\\n",\ " -variable stldoctor.showvicinity \\\n",\ " -command {Ng_STLDoctor vicinity; redraw}\n",\ " label $f.vc.lab -text \"vicinity size\";\n",\ " scale $f.vc.sc -orient horizontal -length 200 -from 0 -to 200 \\\n",\ " -resolution 1 -variable stldoctor.vicinity \\\n",\ " -command { Ng_STLDoctor vicinity; redraw }\n",\ " pack $f.vc.bu $f.vc.lab $f.vc.sc -expand yes\n",\ "\n",\ " frame $f.ge -relief groove -borderwidth 3\n",\ " pack $f.ge -fill x\n",\ " button $f.ge.neighbourangles -text \"calc neighbourangles\" -command {Ng_STLDoctor neighbourangles}\n",\ " button $f.ge.showcoords -text \"show coords of touched triangle\" -command {Ng_STLDoctor showcoords}\n",\ " button $f.ge.moveptm -text \"move point to middle of trianglepoints\" -command {Ng_STLDoctor movepointtomiddle; redraw}\n",\ " button $f.ge.destroy0trigs -text \"destroy 0-volume triangles\" -command {Ng_STLDoctor destroy0trigs}\n",\ " pack $f.ge.neighbourangles $f.ge.showcoords $f.ge.moveptm $f.ge.destroy0trigs -expand yes \n",\ "\n",\ "\n",\ " button $f.ge.cancle -text \"Done\" -command {destroy .stldoctor_dlg }\n",\ " pack $f.ge.cancle -expand yes\n",\ "\n",\ " set f [$wd.nb subwidget topology]\n",\ "\n",\ " frame $f.oc -relief groove -borderwidth 3\n",\ " pack $f.oc -fill x\n",\ " button $f.oc.bu -text \"invert orientation of selected trig\" -command {Ng_STLDoctor invertselectedtrig; redraw }\n",\ " button $f.oc.bu2 -text \"orient after selected trig\" -command {Ng_STLDoctor orientafterselectedtrig; redraw }\n",\ " pack $f.oc.bu $f.oc.bu2 -side left -expand yes\n",\ "\n",\ " button $f.toperr -text \"mark inconsistent triangles\" -command {Ng_STLDoctor marktoperrortrigs; redraw }\n",\ "\n",\ " button $f.deltrig -text \"delete selected triangle\" -command {Ng_STLDoctor deleteselectedtrig; redraw }\n",\ " button $f.geosmooth -text \"geometric smoothing\" -command {Ng_STLDoctor smoothgeometry; redraw }\n",\ "\n",\ " pack $f.toperr $f.deltrig $f.geosmooth\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ " set f [$wd.nb subwidget edges]\n",\ "\n",\ "\n",\ " frame $f.be -relief groove -borderwidth 3 \n",\ " pack $f.be -fill x\n",\ " label $f.be.lab -text \"build edges with yellow angle:\";\n",\ " scale $f.be.sc -orient horizontal -length 200 -from 0 -to 100 \\\n",\ " -resolution 0.5\n",\ " $f.be.sc config -variable stloptions.yangle \n",\ " $f.be.sc config -command { Ng_SetSTLParameters; Ng_STLDoctor buildedges; redraw }\n",\ " label $f.be.lab2 -text \"continue edges with yellow angle:\";\n",\ " scale $f.be.sc2 -orient horizontal -length 200 -from 0 -to 100 \\\n",\ " -resolution 0.5\n",\ " $f.be.sc2 config -variable stloptions.contyangle \n",\ " $f.be.sc2 config -command { Ng_SetSTLParameters; Ng_STLDoctor buildedges; redraw }\n",\ "\n",\ "\n",\ "\n",\ " button $f.be.buildedges -text \"Build Edges\" -command {Ng_STLDoctor buildedges; redraw}\n",\ " pack $f.be.lab $f.be.sc $f.be.lab2 $f.be.sc2 $f.be.buildedges -expand yes\n",\ "\n",\ " frame $f.se\n",\ " pack $f.se -fill x\n",\ " checkbutton $f.se.bu -text \"show excluded\" \\\n",\ " -variable stldoctor.showexcluded \\\n",\ " -command {Ng_STLDoctor; redraw}\n",\ " pack $f.se.bu \n",\ "\n",\ " \n",\ " set edgeselmodevals { 0 1 2 3 4 }\n",\ " set edgeselmodelabs(0) \"no change\" \n",\ " set edgeselmodelabs(1) \"undefined\" \n",\ " set edgeselmodelabs(2) \"confirmed\" \n",\ " set edgeselmodelabs(3) \"candidate\"\n",\ " set edgeselmodelabs(4) \"excluded\"\n",\ "\n",\ " tixOptionMenu $f.edgeselmode -label \"Double Click sets edge :\" \\\n",\ " -options {\n",\ " label.width 19\n",\ " label.anchor e\n",\ " menubutton.width 15\n",\ " } \n",\ "\n",\ " foreach edgeselmodev $edgeselmodevals {\n",\ " $f.edgeselmode add command $edgeselmodev -label $edgeselmodelabs($edgeselmodev)\n",\ " }\n",\ " $f.edgeselmode config -variable stldoctor.edgeselectmode\n",\ " $f.edgeselmode config -command { Ng_STLDoctor }\n",\ " global stldoctor.edgeselectmode\n",\ " pack $f.edgeselmode\n",\ "\n",\ " \n",\ " frame $f.edg -relief groove -borderwidth 3\n",\ " pack $f.edg -fill x\n",\ "\n",\ "\n",\ "\n",\ " frame $f.edg.f0\n",\ " pack $f.edg.f0\n",\ " button $f.edg.f0.confirmedge -text \"confirm\" -command {Ng_STLDoctor confirmedge; redraw}\n",\ " button $f.edg.f0.candidateedge -text \"candidate\" -command {Ng_STLDoctor candidateedge; redraw}\n",\ " button $f.edg.f0.excludeedge -text \"exclude\" -command {Ng_STLDoctor excludeedge; redraw}\n",\ " button $f.edg.f0.undefinededge -text \"undefined\" -command {Ng_STLDoctor undefinededge; redraw}\n",\ " pack $f.edg.f0.confirmedge $f.edg.f0.candidateedge $f.edg.f0.excludeedge $f.edg.f0.undefinededge -side left\n",\ "\n",\ " frame $f.edg.fa\n",\ " pack $f.edg.fa\n",\ " button $f.edg.fa.setallundefined -text \"all undefined\" -command {Ng_STLDoctor setallundefinededges; redraw}\n",\ " button $f.edg.fa.erasecandidates -text \"candidates to undefined\" -command {Ng_STLDoctor erasecandidateedges; redraw}\n",\ " pack $f.edg.fa.setallundefined $f.edg.fa.erasecandidates -side left\n",\ "\n",\ "\n",\ " frame $f.edg.fb\n",\ " pack $f.edg.fb\n",\ " button $f.edg.fb.confirmcandidates -text \"candidates to confirmed\" -command {Ng_STLDoctor confirmcandidateedges; redraw}\n",\ " button $f.edg.fb.confirmedtocandidates -text \"confirmed to candidates\" -command {Ng_STLDoctor confirmedtocandidateedges; redraw}\n",\ " pack $f.edg.fb.confirmcandidates $f.edg.fb.confirmedtocandidates -side left\n",\ "\n",\ " frame $f.edg.f1\n",\ " frame $f.edg.f2\n",\ " frame $f.edg.f3\n",\ " frame $f.edg.f4\n",\ " pack $f.edg.f1 $f.edg.f2 $f.edg.f3 $f.edg.f4\n",\ "\n",\ " button $f.edg.f1.exportedges -text \"export edges\" -command {Ng_STLDoctor exportedges}\n",\ " button $f.edg.f1.importedges -text \"import edges\" -command {Ng_STLDoctor importedges; redraw}\n",\ " button $f.edg.f1.saveedgedata -text \"save edgedata\" \\\n",\ " -command { \n",\ " set types {\n",\ " {\"Netgen Edgedata\" {.ned} } \n",\ " }\n",\ " set file [tk_getSaveFile -filetypes $types -defaultextension \".ned\"]\n",\ " if {$file != \"\"} {\n",\ " Ng_STLDoctor saveedgedata $file\n",\ " }\n",\ " }\n",\ "\n",\ " button $f.edg.f1.loadedgedata -text \"load edgedata\" \\\n",\ " -command { \n",\ " set types {\n",\ " {\"Netgen Edgedata\" {.ned} }\n",\ " }\n",\ " set file [tk_getOpenFile -filetypes $types -defaultextension \".ned\"]\n",\ " if {$file != \"\"} {\n",\ " Ng_STLDoctor loadedgedata $file \n",\ " puts \"loading done\"\n",\ " \n",\ " redraw\n",\ " \n",\ " }\n",\ " } \n",\ "\n",\ " button $f.edg.f1.importAVLedges -text \"import AVL edges\" \\\n",\ " -command {\n",\ " set types {{\"Edge file\" {.edg }}}\n",\ "\n",\ " set file [tk_getOpenFile -filetypes $types -defaultextension \".edg\"]\n",\ " if {$file != \"\"} {\n",\ " Ng_STLDoctor importexternaledges $file; \n",\ " }\n",\ " }\n",\ "\n",\ " pack $f.edg.f1.importAVLedges $f.edg.f1.loadedgedata $f.edg.f1.saveedgedata -side left\n",\ "\n",\ " frame $f.edg2 -relief groove -borderwidth 3\n",\ " pack $f.edg2 -fill x\n",\ "\n",\ "\n",\ " label $f.edg2.lab -text \"length (%):\"\n",\ " scale $f.edg2.sc -orient horizontal -length 200 -from 0 -to 100 \\\n",\ " -resolution 0.5 \\\n",\ " -variable stldoctor.longlinefact \n",\ "\n",\ " button $f.edg2.undoedge -text \"undo last edge change\" -command {Ng_STLDoctor undoedgechange; redraw}\n",\ " \n",\ " pack $f.edg2.undoedge -expand yes\n",\ "\n",\ "\n",\ "\n",\ " set f [$wd.nb subwidget normals]\n",\ "\n",\ " frame $f.dt -relief groove -borderwidth 3\n",\ " pack $f.dt -fill x\n",\ " label $f.dt.lab -text \"dirty triangle factor\";\n",\ " entry $f.dt.ent -width 5 -relief sunken \\\n",\ " -textvariable stldoctor.dirtytrigfact\n",\ " pack $f.dt.ent $f.dt.lab -side left -expand yes\n",\ "\n",\ " frame $f.srt -relief groove -borderwidth 3\n",\ " pack $f.srt -fill x\n",\ " button $f.srt.bu -text \"smooth reverted triangles geometric\" -command {Ng_STLDoctor smoothrevertedtrigs; redraw }\n",\ " entry $f.srt.ent -width 5 -relief sunken \\\n",\ " -textvariable stldoctor.smoothangle\n",\ " pack $f.srt.ent $f.srt.bu -side left -expand yes\n",\ "\n",\ " frame $f.bdt -relief groove -borderwidth 3\n",\ " pack $f.bdt -fill x\n",\ " button $f.bdt.bu -text \"mark dirty triangles\" -command {Ng_STLDoctor markdirtytrigs; redraw }\n",\ " button $f.bdt.bu2 -text \"smooth dirty triangles normal\" -command {Ng_STLDoctor smoothdirtytrigs; redraw }\n",\ " pack $f.bdt.bu $f.bdt.bu2 -side left -expand yes\n",\ "\n",\ " \n",\ " frame $f.sno -relief groove -borderwidth 3\n",\ " pack $f.sno\n",\ " \n",\ " label $f.sno.labrough -text \"rough\"\n",\ " scale $f.sno.scsmooth -orient horizontal -length 100 -from 0 -to 0.8 \\\n",\ " -resolution 0.01 -variable stldoctor.smoothnormalsweight \\\n",\ " -command { Ng_SetSTLParameters }\n",\ " label $f.sno.labsmooth -text \"smooth\"\n",\ " button $f.sno.smoothnormals -text \"smooth normals\" -command { Ng_STLDoctor smoothnormals; redraw}\n",\ "\n",\ "\n",\ "\n",\ " pack $f.sno.labrough $f.sno.scsmooth $f.sno.labsmooth $f.sno.smoothnormals -side left -padx 5\n",\ "\n",\ " frame $f.no -relief groove -borderwidth 3\n",\ " pack $f.no -fill x\n",\ "\n",\ " button $f.no.marknonsmoothnormals -text \"mark non-smooth triangles\" -command {Ng_STLDoctor marknonsmoothnormals; redraw}\n",\ " button $f.no.calcnormals -text \"calculate normals from geometry\" -command {Ng_STLDoctor calcnormals; redraw}\n",\ "\n",\ " pack $f.no.marknonsmoothnormals $f.no.calcnormals -expand yes\n",\ "\n",\ "\n",\ " set f [$wd.nb subwidget advanced]\n",\ "\n",\ "\n",\ " frame $f.sc\n",\ " pack $f.sc -fill x\n",\ " checkbutton $f.sc.bu -text \"spiral check\" \\\n",\ " -variable stldoctor.spiralcheck \\\n",\ " -command {Ng_STLDoctor;} \n",\ " checkbutton $f.sc.bu2 -text \"cone check\" \\\n",\ " -variable stldoctor.conecheck \\\n",\ " -command {Ng_STLDoctor;} \n",\ " pack $f.sc.bu $f.sc.bu2\n",\ "\n",\ "\n",\ " tixControl $f.gtol -label \"load-geometry tolerance factor\" -integer false \\\n",\ " -variable stldoctor.geom_tol_fact \\\n",\ " -options {\n",\ " entry.width 8\n",\ " label.width 30\n",\ " label.anchor e\n",\ " } \n",\ " pack $f.gtol\n",\ "\n",\ " button $f.adap -text \"Apply\" -command {\n",\ " [.stldoctor_dlg.nb subwidget advanced].gtol invoke\n",\ " Ng_STLDoctor; \n",\ " }\n",\ " pack $f.adap -expand yes\n",\ "\n",\ "\n",\ " wm withdraw $wd\n",\ " wm geom $wd +100+100\n",\ " wm deiconify $wd\n",\ " wm title $wd \"STL Doctor\"\n",\ "\n",\ " focus $wd\n",\ "}\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "proc meshdoctordialog { } {\n",\ "\n",\ " set w .meshdoc_dlg\n",\ " global meshdoctor.active\n",\ "\n",\ " if {[winfo exists .meshdoc_dlg] == 1} {\n",\ " wm withdraw $w\n",\ " wm deiconify $w\n",\ " focus $w \n",\ " } {\n",\ " toplevel $w\n",\ "\n",\ " set meshdoctor.active 1\n",\ " Ng_MeshDoctor;\n",\ "\n",\ "\n",\ " frame $w.vis -relief groove -borderwidth 3\n",\ " pack $w.vis\n",\ "\n",\ " checkbutton $w.vis.showfilledtrigs -text \"Show filled triangles\" \\\n",\ " -variable viewoptions.drawfilledtrigs \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ " \n",\ " checkbutton $w.vis.showedges -text \"Show edges\" \\\n",\ " -variable viewoptions.drawedges \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ " \n",\ "\n",\ " checkbutton $w.vis.showoutline -text \"Show Triangle Outline\" \\\n",\ " -variable viewoptions.drawoutline \\\n",\ " -command { Ng_SetVisParameters; redraw }\n",\ "\n",\ " pack $w.vis.showfilledtrigs $w.vis.showoutline $w.vis.showedges\n",\ "\n",\ " tixControl $w.markedgedist -label \"Mark edge dist: \" -integer true \\\n",\ " -min 0 -max 999 \\\n",\ " -variable meshdoc.markedgedist \\\n",\ " -options {\n",\ " entry.width 3\n",\ " label.width 20\n",\ " label.anchor e\n",\ " } \\\n",\ " -command {\n",\ " Ng_MeshDoctor markedgedist ${meshdoc.markedgedist}\n",\ " redraw\n",\ " }\n",\ " pack $w.markedgedist\n",\ " \n",\ " button $w.deledge -text \"Delete marked segments\" -command {\n",\ " Ng_MeshDoctor deletemarkedsegments\n",\ " redraw\n",\ " }\n",\ " pack $w.deledge\n",\ " \n",\ " button $w.close -text \"Close\" -command { \n",\ " set meshdoctor.active 0;\n",\ " Ng_MeshDoctor;\n",\ " destroy .meshdoc_dlg \n",\ " }\n",\ " pack $w.close -expand yes\n",\ " \n",\ " wm withdraw $w\n",\ " wm geom $w +100+100\n",\ " wm deiconify $w\n",\ " wm title $w \"Mesh Doctor\"\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "proc qualityviewdialog { show } {\n",\ "\n",\ " set w .qualityview_dlg\n",\ " \n",\ " if {[winfo exists .qualityview_dlg] == 1} {\n",\ "\n",\ " if { $show == 1 } {\n",\ " wm withdraw .qualityview_dlg\n",\ " wm deiconify $w\n",\ " focus $w \n",\ " } {\n",\ " wm withdraw $w\n",\ " }\n",\ " } {\n",\ " toplevel $w\n",\ " \n",\ " set c $w.c\n",\ "\n",\ " canvas $c -relief raised -width 450 -height 300\n",\ " pack $w.c -side top -fill x\n",\ "\n",\ " set plotFont {Helvetica 12}\n",\ " set smallFont {Helvetica 12}\n",\ "\n",\ " $c create line 100 250 400 250 -width 2\n",\ " $c create line 100 250 100 50 -width 2\n",\ "\n",\ " for {set i 0} {$i <= 10} {incr i} {\n",\ " set x [expr {100 + ($i*30)}]\n",\ " $c create line $x 250 $x 245 -width 2\n",\ " if { [expr {$i % 2}] == 0 } {\n",\ " $c create text $x 254 -text [format %1.1f [expr 0.1*$i]] -anchor n -font $plotFont\n",\ " }\n",\ " }\n",\ "\n",\ " global qualbar\n",\ " global qualbarnull\n",\ " global qualbaraxis\n",\ "\n",\ " for {set i 0} {$i <= 5} {incr i} {\n",\ " set y [expr {250 - ($i*40)}]\n",\ " $c create line 100 $y 105 $y -width 2\n",\ "\n",\ " set qualbaraxis($i) \\\n",\ " [$c create text 96 $y -text [expr $i*50].0 -anchor e -font $plotFont]\n",\ " }\n",\ "\n",\ " for {set i 0} {$i < 20} {incr i} {\n",\ " set x1 [expr {100 + ($i*15) + 2}]\n",\ " set x2 [expr {$x1+10}]\n",\ " set y [expr {250 - 10 * $i}]\n",\ " set qualbar($i) [$c create rectangle $x1 250 $x2 245 -fill blue]\n",\ " set qualbarnull($i) [$c create text [expr {($x1+$x2)/2}] 245 -text 0 -anchor s -font $smallFont -fill blue] \n",\ " }\n",\ "\n",\ " frame $w.bu\n",\ " pack $w.bu\n",\ " \n",\ " button $w.close -text \"Close\" \\\n",\ " -command { \n",\ " wm withdraw .qualityview_dlg\n",\ " set viewqualityplot 0\n",\ " }\n",\ " pack $w.close\n",\ " \n",\ " \n",\ " if { $show == 1 } {\n",\ " wm withdraw $w\n",\ " wm geom $w +100+100\n",\ " wm deiconify $w\n",\ " wm title $w \"Mesh Quality\"\n",\ " focus $w\n",\ " }\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "proc memusedialog { show } {\n",\ "\n",\ " set w .memuse_dlg\n",\ " \n",\ " if {[winfo exists .memuse_dlg] == 1} {\n",\ "\n",\ " if { $show == 1 } {\n",\ " wm withdraw .memuse_dlg\n",\ " wm deiconify $w\n",\ " focus $w \n",\ " } {\n",\ " wm withdraw $w\n",\ " }\n",\ " } {\n",\ " toplevel $w\n",\ " \n",\ " set c $w.c\n",\ "\n",\ " canvas $c -relief raised -width 600 -height 300\n",\ " pack $w.c -side top -fill x\n",\ "\n",\ " set plotFont {Helvetica 18}\n",\ " set smallFont {Helvetica 12}\n",\ "\n",\ "\n",\ " global memmark\n",\ " for {set i 0} {$i < 512} { incr i } {\n",\ " set memmark($i) [$c create line [expr 50+$i] 50 [expr 50+$i] 70 -fill blue]\n",\ " }\n",\ "\n",\ "\n",\ " set plotFont {Helvetica 18}\n",\ " set smallFont {Helvetica 12}\n",\ "\n",\ " $c create text 50 90 -text \"0 GB\" -anchor n -font $plotFont\n",\ " $c create text 178 90 -text \"1 GB\" -anchor n -font $plotFont\n",\ " $c create text 306 90 -text \"2 GB\" -anchor n -font $plotFont\n",\ " $c create text 434 90 -text \"3 GB\" -anchor n -font $plotFont\n",\ " $c create text 562 90 -text \"4 GB\" -anchor n -font $plotFont\n",\ "\n",\ "\n",\ " frame $w.bu\n",\ " pack $w.bu\n",\ " \n",\ " button $w.close -text \"Close\" \\\n",\ " -command { \n",\ " wm withdraw .memuse_dlg\n",\ " set memuseplot 0\n",\ " }\n",\ " pack $w.close\n",\ " \n",\ " if { $show == 1 } {\n",\ " wm withdraw $w\n",\ " wm geom $w +100+100\n",\ " wm deiconify $w\n",\ " wm title $w \"Memory Usage\"\n",\ " focus $w\n",\ " }\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "proc STLinfodialog { show } {\n",\ "\n",\ " set w .STLinfo_dlg\n",\ " \n",\ " if {[winfo exists .STLinfo_dlg] == 1} {\n",\ "\n",\ " if { $show == 1 } {\n",\ " wm withdraw .STLinfo_dlg\n",\ " wm deiconify $w\n",\ " focus $w \n",\ " } {\n",\ " wm withdraw $w\n",\ " }\n",\ " } {\n",\ " toplevel $w\n",\ " \n",\ " set c $w.c\n",\ "\n",\ " canvas $c -relief raised -width 450 -height 300\n",\ " pack $w.c -side top -fill x\n",\ "\n",\ " set plotFont {Helvetica 18}\n",\ " set smallFont {Helvetica 12}\n",\ "\n",\ " $c create line 100 250 400 250 -width 2\n",\ " $c create line 100 250 100 50 -width 2\n",\ "\n",\ " frame $w.bu\n",\ " pack $w.bu\n",\ " \n",\ " button $w.close -text \"Close\" \\\n",\ " -command { \n",\ " wm withdraw .STLinfo_dlg\n",\ " }\n",\ " pack $w.close\n",\ " \n",\ " \n",\ " if { $show == 1 } {\n",\ " wm withdraw $w\n",\ " wm geom $w +100+100\n",\ " wm deiconify $w\n",\ " wm title $w \"STL Geometry Info\"\n",\ " focus $w\n",\ " }\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "proc editprimitivedialog2 { name } {\n",\ "\n",\ " global w classname\n",\ "\n",\ " set w .ep_dlg\n",\ " toplevel .$w\n",\ "\n",\ " Ng_GetPrimitiveData $name classname valuelist\n",\ " \n",\ " \n",\ " label $w.lab1 -text \"Primitive Name: $name\";\n",\ " label $w.lab2 -text \"Primitive Class: $classname\";\n",\ " pack $w.lab1 $w.lab2 -fill x -pady 1m -padx 5m \n",\ " \n",\ " frame $w.specific -relief groove\n",\ "\n",\ " global spec\n",\ " set spec(sphere) { cx cy cz rad }\n",\ " set spec(cylinder) { ax ay az bx by bz rad }\n",\ " set spec(plane) { px py pz nx ny nz }\n",\ " set spec(cone) { ax ay az bx by bz ra rb }\n",\ " set spec(brick) { p1x p1y p1z p2x p2y p2z p3x p3y p3z p4x p4y p4z } \n",\ " \n",\ " set cnt 0\n",\ " foreach field $spec($classname) {\n",\ "\n",\ " frame $w.specific.f$cnt \n",\ " pack $w.specific.f$cnt -side top -anchor ne\n",\ "\n",\ " label $w.specific.f$cnt.lab -text \"$field\"\n",\ " entry $w.specific.f$cnt.ent -textvariable dataval($cnt) \\\n",\ " -width 6 -relief sunken\n",\ " pack $w.specific.f$cnt.ent $w.specific.f$cnt.lab -side right\n",\ " $w.specific.f$cnt.ent delete 0 end\n",\ " $w.specific.f$cnt.ent insert 0 [lindex $valuelist $cnt]\n",\ " set cnt [expr $cnt + 1]\n",\ " }\n",\ " pack $w.specific\n",\ "\n",\ "\n",\ " button $w.cancel -text \"cancel\" -command {\n",\ " destroy $w \n",\ " }\n",\ "\n",\ " button $w.ok -text \"ok\" -command {\n",\ "\n",\ " set valuelist \"\"\n",\ " set cnt 0\n",\ " foreach field $spec($classname) {\n",\ " lappend valuelist $dataval($cnt)\n",\ " set cnt [expr $cnt + 1]\n",\ " }\n",\ " Ng_SetPrimitiveData $name $valuelist\n",\ " destroy $w\n",\ " }\n",\ " pack $w.cancel $w.ok -side left -expand yes\n",\ "\n",\ " bind $w { $w.ok invoke}\n",\ " bind $w { $w.cancel invoke}\n",\ " \n",\ "\n",\ " wm withdraw $w\n",\ " wm geom $w +100+100\n",\ " wm deiconify $w\n",\ "\n",\ " focus $w.specific.f0.ent\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "proc editprimitivedialog { } {\n",\ " global w\n",\ "\n",\ " set w .ep_dlg\n",\ " toplevel $w\n",\ "\n",\ " frame $w.frame -borderwidth 5m\n",\ " pack $w.frame -side top -expand yes -fill y\n",\ "\n",\ " listbox $w.frame.list -yscroll \"$w.frame.scroll set\" -setgrid 1 -height 12\n",\ " scrollbar $w.frame.scroll -command \"$w.frame.list yview\"\n",\ " pack $w.frame.scroll -side right -fill y\n",\ " pack $w.frame.list -side left -expand 1 -fill both\n",\ " \n",\ "\n",\ " Ng_GetPrimitiveList primlist\n",\ " foreach el $primlist {\n",\ " $w.frame.list insert end $el }\n",\ "\n",\ " button $w.cancel -text \"cancel\" -command { destroy $w }\n",\ " button $w.ok -text \"ok\" -command {\n",\ " set name [.ep_dlg.frame.list get active]\n",\ " puts \"name=($name)\"\n",\ " destroy $w\n",\ " if { $name != \"\" } { editprimitivedialog2 $name }\n",\ " }\n",\ " \n",\ " bind $w { $w.cancel invoke }\n",\ " bind $w { $w.ok invoke }\n",\ " \n",\ "\n",\ " pack $w.cancel $w.ok -side left -expand yes\n",\ "\n",\ " wm withdraw $w\n",\ " wm geom $w +100+100\n",\ " wm deiconify $w\n",\ "\n",\ " focus $w.frame.list\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "proc newprimitivedialog { } {\n",\ "\n",\ " global w name\n",\ "\n",\ " set w .ap_dlg\n",\ " \n",\ " toplevel $w\n",\ "\n",\ " set name \"\"\n",\ " frame $w.f1\n",\ " pack $w.f1 -pady 2m\n",\ " label $w.f1.lab -text \"Primitive Name: \";\n",\ " entry $w.f1.ent -width 5 -relief sunken \\\n",\ " -textvariable name\n",\ " pack $w.f1.lab $w.f1.ent -side left\n",\ " \n",\ " frame $w.frame -borderwidth .5c\n",\ " pack $w.frame -side top -expand yes -fill y\n",\ "\n",\ " listbox $w.frame.list -yscroll \"$w.frame.scroll set\" -setgrid 1 -height 8 \n",\ " scrollbar $w.frame.scroll -command \"$w.frame.list yview\"\n",\ " pack $w.frame.scroll -side right -fill y\n",\ " pack $w.frame.list -side left -expand 1 -fill both\n",\ " \n",\ " $w.frame.list insert 0 sphere cylinder plane cone brick\n",\ " $w.frame.list activate 0\n",\ " \n",\ " button $w.ok -text \"ok\" -command {\n",\ " Ng_CreatePrimitive [$w.frame.list get active] $name\n",\ " destroy $w\n",\ " editprimitivedialog2 $name\n",\ " }\n",\ "\n",\ " button $w.cancel -text \"cancel\" -command {\n",\ " destroy $w\n",\ " }\n",\ " \n",\ " pack $w.cancel $w.ok -side left -expand yes -pady 2m\n",\ "\n",\ "\n",\ " bind $w { $w.cancel invoke }\n",\ " bind $w { $w.ok invoke }\n",\ "\n",\ " wm withdraw $w\n",\ " wm geom $w +100+100\n",\ " wm deiconify $w\n",\ "\n",\ " focus $w.f1.ent\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "proc newsoliddialog { } {\n",\ "\n",\ " global w name val sollist\n",\ "\n",\ " set w .ns_dlg\n",\ " toplevel $w\n",\ "\n",\ " set name \"\"\n",\ " frame $w.f1\n",\ " label $w.f1.lab -text \"Solid Name: \";\n",\ " entry $w.f1.ent -width 5 -relief sunken \\\n",\ " -textvariable name\n",\ " $w.f1.ent delete 0 end\n",\ " button $w.f1.getsel -text \"Get Selected\" -command { \n",\ " $w.f1.ent delete 0 end\n",\ " $w.f1.ent insert 0 [$w.f3.list get active]\n",\ " $w.bu.get invoke\n",\ " }\n",\ " pack $w.f1.getsel -side bottom\n",\ " pack $w.f1.ent $w.f1.lab -side right\n",\ "\n",\ "\n",\ " frame $w.f3 -borderwidth .5c\n",\ " listbox $w.f3.list -yscroll \"$w.f3.scroll set\" -setgrid 1 -height 12\n",\ " scrollbar $w.f3.scroll -command \"$w.f3.list yview\"\n",\ " pack $w.f3.scroll -side right -fill y\n",\ " pack $w.f3.list -side left -expand 1 -fill both\n",\ " \n",\ " Ng_GetSolidList sollist\n",\ " foreach el $sollist {\n",\ " $w.f3.list insert end $el }\n",\ "\n",\ " frame $w.f2\n",\ " label $w.f2.lab -text \"Solid Description: \";\n",\ " pack $w.f2.lab\n",\ "\n",\ "\n",\ " entry $w.f2.ent -width 100 -relief sunken \\\n",\ " -textvariable val -xscrollcommand \"$w.f2.scr set\"\n",\ " scrollbar $w.f2.scr -relief sunken -orient horiz -command \\\n",\ " \"$w.f2.ent xview\"\n",\ " $w.f2.ent delete 0 end\n",\ " pack $w.f2.ent $w.f2.scr -fill x\n",\ "\n",\ "\n",\ "\n",\ " frame $w.bu\n",\ " button $w.bu.close -text \"close\" -command {\n",\ " destroy $w\n",\ " }\n",\ "\n",\ " button $w.bu.get -text \"get data\" -command {\n",\ " Ng_GetSolidData $name val\n",\ " }\n",\ "\n",\ " button $w.bu.set -text \"set data\" -command {\n",\ " Ng_SetSolidData $name $val\n",\ " }\n",\ "\n",\ " pack $w.bu.get $w.bu.set $w.bu.close -side left \n",\ "\n",\ "\n",\ " pack $w.bu -pady 5 -side bottom ; pack $w.f2 -pady 5 -side bottom ; pack $w.f1 -pady 5 -side left ; pack $w.f3 -side left -expand yes -fill y ;\n",\ "\n",\ "\n",\ " bind $w { $w.bu.close invoke }\n",\ "\n",\ " wm withdraw $w\n",\ " wm geom $w +100+100\n",\ " wm deiconify $w\n",\ "\n",\ " focus $w\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "proc toplevelproperties { w solname surfname } {\n",\ "\n",\ " global properties\n",\ "\n",\ " Ng_TopLevel getprop $solname $surfname properties\n",\ "\n",\ "\n",\ " set w .tlprop_dlg\n",\ "\n",\ " if {[winfo exists $w] == 1} {\n",\ " wm withdraw $w\n",\ " wm deiconify $w\n",\ " focus $w \n",\ " } {\n",\ " toplevel $w\n",\ " \n",\ " label $w.lab1 -text \"Red\"\n",\ " scale $w.scale1 -orient horizontal -length 300 -from 0 -to 1 \\\n",\ " -resolution 0.01 -tickinterval 0.2 \\\n",\ " -command { Ng_TopLevel setprop $solname $surfname properties; redraw } -variable properties(red)\n",\ " \n",\ " label $w.lab2 -text \"Green\"\n",\ " scale $w.scale2 -orient horizontal -length 300 -from 0 -to 1 \\\n",\ " -resolution 0.01 -tickinterval 0.2 \\\n",\ " -command { Ng_TopLevel setprop $solname $surfname properties; redraw } -variable properties(green)\n",\ " \n",\ " label $w.lab3 -text \"Blue\"\n",\ " scale $w.scale3 -orient horizontal -length 300 -from 0 -to 1 \\\n",\ " -resolution 0.01 -tickinterval 0.2 \\\n",\ " -command { Ng_TopLevel setprop $solname $surfname properties; redraw } -variable properties(blue)\n",\ "\n",\ " \n",\ " pack $w.lab1 $w.scale1 $w.lab2 $w.scale2 $w.lab3 $w.scale3\n",\ "\n",\ " checkbutton $w.cb4 -text \"Visible\" \\\n",\ " -command { Ng_TopLevel setprop $solname $surfname properties; redraw } \\\n",\ " -variable properties(visible)\n",\ " \n",\ " checkbutton $w.cb5 -text \"Transparent\" \\\n",\ " -command { Ng_TopLevel setprop $solname $surfname properties; redraw } \\\n",\ " -variable properties(transp)\n",\ " \n",\ " \n",\ " pack $w.cb4 $w.cb5\n",\ " \n",\ " \n",\ " frame $w.bu\n",\ " pack $w.bu -fill x\n",\ " button $w.bu.ok -text \"Ok\" -command \"destroy .tlprop_dlg\"\n",\ " pack $w.bu.ok -expand yes\n",\ " \n",\ " wm withdraw $w\n",\ " wm geom $w +100+100\n",\ " wm deiconify $w\n",\ " focus $w\n",\ " }\n",\ " wm title $w \"Properties $solname $surfname\"\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "proc topleveldialog { } {\n",\ "\n",\ " global w name val sollist\n",\ "\n",\ " set w .tl_dlg\n",\ " toplevel $w\n",\ "\n",\ "\n",\ "\n",\ " frame $w.sol -borderwidth .5c\n",\ " listbox $w.sol.list -yscroll \"$w.sol.scroll set\" -setgrid 1 -height 12\n",\ " scrollbar $w.sol.scroll -command \"$w.sol.list yview\"\n",\ " pack $w.sol.scroll -side right -fill y\n",\ " pack $w.sol.list -side left -expand 1 -fill both\n",\ " \n",\ " Ng_GetSolidList sollist\n",\ " foreach el $sollist {\n",\ " $w.sol.list insert end $el }\n",\ " Ng_GetPrimitiveList sollist\n",\ " foreach el $sollist {\n",\ " $w.sol.list insert end $el }\n",\ "\n",\ "\n",\ "\n",\ "\n",\ " frame $w.sul -borderwidth .5c\n",\ " listbox $w.sul.list -yscroll \"$w.sul.scroll set\" -setgrid 1 -height 12\n",\ " scrollbar $w.sul.scroll -command \"$w.sul.list yview\"\n",\ " pack $w.sul.scroll -side right -fill y\n",\ " pack $w.sul.list -side left -expand 1 -fill both\n",\ " \n",\ " Ng_GetSurfaceList sollist\n",\ " foreach el $sollist {\n",\ " $w.sul.list insert end $el }\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ " frame $w.topl -borderwidth .5c\n",\ " listbox $w.topl.list -yscroll \"$w.topl.scroll set\" -setgrid 1 -height 12 \\\n",\ " -command { puts hi }\n",\ " scrollbar $w.topl.scroll -command \"$w.topl.list yview\"\n",\ " pack $w.topl.scroll -side right -fill y\n",\ " pack $w.topl.list -side left -expand 1 -fill both\n",\ " \n",\ " Ng_TopLevel getlist sollist\n",\ " puts $sollist\n",\ " foreach el $sollist {\n",\ " set hel \"[ lindex $el 0 ]\"\n",\ " if { [ llength $el ] == 2 } {\n",\ " set hel \"[ lindex $el 1 ] on [ lindex $el 0 ]\"\n",\ " }\n",\ " $w.topl.list insert end $hel \n",\ " }\n",\ "\n",\ "\n",\ " frame $w.bu\n",\ "\n",\ " button $w.bu.close -text \"close\" -command {\n",\ " destroy $w\n",\ " }\n",\ " button $w.bu.addsol -text \"Add Solid\" -command {\n",\ " set solname [$w.sol.list get active]\n",\ " Ng_TopLevel set $solname \"\"\n",\ " Ng_ParseGeometry\n",\ " $w.topl.list insert end $solname\n",\ " }\n",\ "\n",\ " button $w.bu.addsurf -text \"Add Surface\" -command {\n",\ " set solname [$w.sol.list get active]\n",\ " set surfname [$w.sul.list get active]\n",\ " Ng_TopLevel set $solname $surfname\n",\ " Ng_ParseGeometry\n",\ " puts \"$solname on $surfname\"\n",\ " $w.topl.list insert end \"$surfname on $solname\"\n",\ " }\n",\ "\n",\ " button $w.bu.remsol -text \"Remove\" -command {\n",\ " set solname [$w.topl.list get active]\n",\ " set surfname \"\"\n",\ " if { [llength $solname] == 3 } {\n",\ " set surfname [lindex $solname 0]\n",\ " set solname [lindex $solname 2]\n",\ " }\n",\ " Ng_TopLevel remove $solname $surfname\n",\ " Ng_ParseGeometry\n",\ " $w.topl.list delete active\n",\ " }\n",\ "\n",\ " button $w.bu.prop -text \"Properties\" -command {\n",\ " set solname [$w.topl.list get active]\n",\ " set surfname \"\"\n",\ " if { [llength $solname] == 3 } {\n",\ " set surfname [lindex $solname 0]\n",\ " set solname [lindex $solname 2]\n",\ " }\n",\ " toplevelproperties tlp $solname $surfname\n",\ " }\n",\ "\n",\ "\n",\ " \n",\ "\n",\ " pack $w.bu.close $w.bu.addsol $w.bu.addsurf $w.bu.remsol $w.bu.prop -side left \n",\ "\n",\ "\n",\ " pack $w.bu -side bottom\n",\ " pack $w.sol -side left -expand yes -fill y ; pack $w.sul -side left -expand yes -fill y ; pack $w.topl -side left -expand yes -fill y ;\n",\ "\n",\ " bind $w { $w.bu.close invoke }\n",\ "\n",\ " wm withdraw $w\n",\ " wm geom $w +100+100\n",\ " wm deiconify $w\n",\ "\n",\ " focus $w\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "proc topleveldialog2 { } {\n",\ " set w .tl2_dlg\n",\ " \n",\ " if {[winfo exists .tl2_dlg] == 1} {\n",\ " wm withdraw $w\n",\ " wm deiconify $w\n",\ " focus $w \n",\ " } {\n",\ " toplevel $w\n",\ "\n",\ " global name val sollist\n",\ "\n",\ " frame $w.topl -borderwidth .5c\n",\ " listbox $w.topl.list -yscroll \"$w.topl.scroll set\" -setgrid 1 -height 12\n",\ " scrollbar $w.topl.scroll -command \"$w.topl.list yview\"\n",\ " pack $w.topl.scroll -side right -fill y\n",\ " pack $w.topl.list -side left -expand 1 -fill both\n",\ " \n",\ " Ng_TopLevel getlist sollist\n",\ " puts $sollist\n",\ " set i 1\n",\ " foreach el $sollist {\n",\ " set hel \"$i: [ lindex $el 0 ]\"\n",\ " if { [ llength $el ] == 2 } {\n",\ " set hel \"$i: [ lindex $el 1 ] on [ lindex $el 0 ]\"\n",\ " }\n",\ " incr i\n",\ " $w.topl.list insert end $hel }\n",\ " \n",\ " \n",\ " frame $w.bu\n",\ " \n",\ " button $w.bu.close -text \"close\" -command {\n",\ " destroy .tl2_dlg\n",\ " }\n",\ " \n",\ "\n",\ " button $w.bu.prop -text \"Properties\" -command {\n",\ " set solname [.tl2_dlg.topl.list get active]\n",\ " set surfname \"\"\n",\ " if { [llength $solname] == 2 } {\n",\ " set solname [lindex $solname 1]\n",\ " }\n",\ " if { [llength $solname] == 4 } {\n",\ " set surfname [lindex $solname 1]\n",\ " set solname [lindex $solname 3]\n",\ " }\n",\ " toplevelproperties tlp $solname $surfname\n",\ " }\n",\ " \n",\ " pack $w.bu.close $w.bu.prop -side left \n",\ " pack $w.bu -side bottom\n",\ " pack $w.topl -side left -expand yes -fill y ; \n",\ " bind .tl2_dlg.topl.list {\n",\ " set solname [.tl2_dlg.topl.list get @%x,%y]\n",\ " set surfname \"\"\n",\ " if { [llength $solname] == 2 } {\n",\ " set solname [lindex $solname 1]\n",\ " }\n",\ " if { [llength $solname] == 4 } {\n",\ " set surfname [lindex $solname 1]\n",\ " set solname [lindex $solname 3]\n",\ " }\n",\ " toplevelproperties tlp $solname $surfname\n",\ " }\n",\ " \n",\ " bind .tl2_dlg { .tl2_dlg.bu.close invoke }\n",\ " \n",\ " wm withdraw $w\n",\ " wm geom $w +100+100\n",\ " wm deiconify $w\n",\ " wm title $w \"Top-Level Options\" \n",\ " focus $w\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "proc logwindow { } {\n",\ " set w .logwindow\n",\ " \n",\ " if {[winfo exists .logwindow] == 1} {\n",\ " wm withdraw $w\n",\ " wm deiconify $w\n",\ " focus $w \n",\ " } {\n",\ " toplevel $w\n",\ "\n",\ " text $w.edit -yscroll \"$w.scrolly set\" -setgrid 1 -height 12\n",\ " scrollbar $w.scrolly -command \"$w.edit yview\" \n",\ " pack $w.edit -side left -fill both -expand 1\n",\ " pack $w.scrolly -side left -fill both -expand 0\n",\ "\n",\ " .logwindow.edit insert end \"Netgen Log Window\\n\"\n",\ "\n",\ " wm withdraw $w\n",\ " wm geom $w +100+100\n",\ " wm deiconify $w\n",\ " wm title $w \"Netgen Log\" \n",\ " focus $w\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "set entities [ ]\n",\ "\n",\ "\n",\ "proc occdialogbuildtree {} {\n",\ " global entities\n",\ "\n",\ " set w .occ_dlg\n",\ " set hlist [$w.mtre subwidget hlist]\n",\ "\n",\ " set entities [Ng_GetOCCData getentities]\n",\ " set nrentities [expr [llength $entities]]\n",\ "\n",\ "\n",\ " if {$nrentities != 0} {\n",\ "\n",\ " $hlist add Topology -itemtype text -text \"Topology\"\n",\ " \n",\ " $hlist add Topology/CompSolids -itemtype text -text \"Composite Solids\" -data \"Composite Solids\"\n",\ " $hlist add Topology/FreeSolids -itemtype text -text \"Free Solids\" -data \"Free Solids\"\n",\ " $hlist add Topology/FreeShells -itemtype text -text \"Free Shells\" -data \"Free Shells\"\n",\ " $hlist add Topology/FreeFaces -itemtype text -text \"Free Faces\" -data \"Free Faces\"\n",\ " $hlist add Topology/FreeWires -itemtype text -text \"Free Wires\" -data \"Free Wires\"\n",\ " $hlist add Topology/FreeEdges -itemtype text -text \"Free Edges\" -data \"Free Edges\"\n",\ " $hlist add Topology/FreeVertices -itemtype text -text \"Free Vertices\" -data \"Free Vertices\"\n",\ "\n",\ " \n",\ " set i [expr 0]\n",\ " while {$i < $nrentities} {\n",\ " set entity [lindex $entities [expr $i]]\n",\ " incr i 1\n",\ " set entityname [lindex $entities [expr $i]]\n",\ " $hlist add Topology/$entity -text $entityname -data $entityname\n",\ " incr i 1\n",\ " $w.mtre close Topology/$entity\n",\ " }\n",\ " \n",\ " $w.mtre autosetmode\n",\ " \n",\ " $w.mtre open Topology\n",\ " $w.mtre close Topology/CompSolids\n",\ " $w.mtre close Topology/FreeSolids\n",\ " $w.mtre close Topology/FreeShells\n",\ " $w.mtre close Topology/FreeFaces\n",\ " $w.mtre close Topology/FreeWires\n",\ " $w.mtre close Topology/FreeEdges\n",\ " $w.mtre close Topology/FreeVertices\n",\ " \n",\ " set i [expr 0]\n",\ " while {$i < $nrentities} {\n",\ " set entity [lindex $entities [expr $i]]\n",\ " $w.mtre close Topology/$entity\n",\ " incr i 2\n",\ " }\n",\ " \n",\ " set faces [Ng_OCCCommand getunmeshedfaceinfo] \n",\ " set nrfaces [expr [llength $faces]]\n",\ " if {$nrfaces >= 2} {\n",\ " $hlist add ErrorFaces -itemtype text -text \"Faces with surface meshing error\"\n",\ " $w.mtre open ErrorFaces\n",\ " set i [expr 0]\n",\ " while {$i < $nrfaces} {\n",\ " set entity [lindex $faces [expr $i]]\n",\ " incr i 1\n",\ " set entityname [lindex $faces [expr $i]]\n",\ " $hlist add ErrorFaces/$entity -text $entityname -data $entityname\n",\ " incr i 1\n",\ " }\n",\ " }\n",\ " \n",\ "\n",\ " set faces [Ng_OCCCommand getnotdrawablefaces] \n",\ " set nrfaces [expr [llength $faces]]\n",\ " if {$nrfaces >= 2} {\n",\ " $hlist add NotDrawableFaces -itemtype text -text \"Faces impossible to visualize\"\n",\ " $w.mtre open NotDrawableFaces\n",\ " set i [expr 0]\n",\ " while {$i < $nrfaces} {\n",\ " set entity [lindex $faces [expr $i]]\n",\ " incr i 1\n",\ " set entityname [lindex $faces [expr $i]]\n",\ " $hlist add NotDrawableFaces/$entity -text $entityname -data $entityname\n",\ " incr i 1\n",\ " }\n",\ " }\n",\ "\n",\ "\n",\ " $w.mtre autosetmode\n",\ "\n",\ " puts \"done\"\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "proc rebuildoccdialog {} {\n",\ " if {[winfo exists .occ_dlg] == 1} {\n",\ " [.occ_dlg.mtre subwidget hlist] delete all\n",\ " occdialogbuildtree \n",\ " }\n",\ "}\n",\ "\n",\ "proc checkoccloaded { } {\n",\ " set isoccgeometryloaded [Ng_OCCCommand isoccgeometryloaded]\n",\ " if {$isoccgeometryloaded == 0} {\n",\ " puts \"no IGES/STEP geometry loaded\"\n",\ " destroy .occ_dlg\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "proc selectentity { entityname } {\n",\ " global entities\n",\ " set nrentities [expr [llength $entities]]\n",\ " set i [expr 0]\n",\ " while {$i < $nrentities} {\n",\ " set entitylength []\n",\ " \n",\ " set entity2 [lindex $entities [expr $i]]\n",\ " incr i 1\n",\ " set entityname2 [lindex $entities [expr $i]]\n",\ " incr i 1\n",\ " set entityname2 [string range $entityname2 0 [expr [string length $entityname]-1]]\n",\ " \n",\ " if {$entityname == $entityname2} {\n",\ " set hlist [.occ_dlg.mtre subwidget hlist]\n",\ " .occ_dlg.mtre open Topology\n",\ " set slashpos [string last \"/\" $entity2]\n",\ " set entity3 [string range $entity2 0 [expr $slashpos-1]]\n",\ " while {$slashpos != -1} {\n",\ " .occ_dlg.mtre open Topology/$entity3\n",\ " \n",\ " set slashpos [string last \"/\" $entity3]\n",\ " set entity3 [string range $entity3 0 [expr $slashpos-1]]\n",\ " }\n",\ " $hlist selection clear\n",\ " $hlist see Topology/$entity2\n",\ " $hlist selection set Topology/$entity2\n",\ " } \n",\ " } \n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "proc occdialog { } {\n",\ " \n",\ " uplevel 1 {\n",\ "\n",\ " global entities\n",\ " set selectvisual geometry\n",\ " Ng_SetVisParameters\n",\ " redraw\n",\ "\n",\ " set w .occ_dlg\n",\ " \n",\ " if {[winfo exists .occ_dlg] == 1} {\n",\ " wm withdraw $w\n",\ " wm deiconify $w\n",\ " focus $w \n",\ " } { \n",\ " toplevel $w\n",\ "\n",\ " tixTree $w.mtre -options { separator \"/\" }\n",\ " pack $w.mtre -fill both -expand yes\n",\ "\n",\ " occdialogbuildtree\n",\ "\n",\ " set hlist [$w.mtre subwidget hlist]\n",\ "\n",\ "\n",\ " set solname {\"\"}\n",\ "\n",\ " \n",\ " bind $hlist {\n",\ " set oldsolname {$solname}\n",\ " set solname [[.occ_dlg.mtre subwidget hlist] info selection]\n",\ " if {$solname != \"\" && $oldsolname != $solname } {\n",\ " set seppos [string first \"/\" $solname]\n",\ " set rootname [string range $solname 0 [expr $seppos-1]]\n",\ "\n",\ " set entityname [[.occ_dlg.mtre subwidget hlist] info data $solname]\n",\ " set spacepos [string first \" \" $entityname]\n",\ " set entitytype [string range $entityname 0 [expr $spacepos-1]]\n",\ " set helpstring [string range $entityname [expr $spacepos+1] [expr [string length $entityname]-1]]\n",\ " set spacepos2 [string first \" \" $helpstring]\n",\ " set entitynumber [string range $helpstring 0 [expr $spacepos2-1]]\n",\ " if {$rootname == \"Topology\"} {\n",\ " Ng_OCCCommand highlightentity $entitytype $entitynumber\n",\ " set selectvisual geometry\n",\ " redraw\n",\ " } {\n",\ " set brackpos [string first \" (\" $entityname]\n",\ " if {$brackpos != -1} {\n",\ " set entityname [string range $entityname 0 $brackpos]\n",\ " }\n",\ "\n",\ " selectentity $entityname\n",\ " }\n",\ " }\n",\ " }\n",\ " \n",\ " button $w.cl -text \"Close\" -command {\n",\ " destroy .occ_dlg\n",\ " }\n",\ " \n",\ " button $w.show -text \"Show\" -command {\n",\ " set solname [[.occ_dlg.mtre subwidget hlist] info selection]\n",\ " set entityname [[.occ_dlg.mtre subwidget hlist] info data $solname]\n",\ " set spacepos [string first \" \" $entityname]\n",\ " set entitytype [string range $entityname 0 [expr $spacepos-1]]\n",\ " set helpstring [string range $entityname [expr $spacepos+1] [expr [string length $entityname]-1]]\n",\ " set spacepos2 [string first \" \" $helpstring]\n",\ " set entitynumber [string range $helpstring 0 [expr $spacepos2-1]]\n",\ "\n",\ " Ng_OCCCommand show $entitytype $entitynumber\n",\ " set selectvisual geometry\n",\ " redraw\n",\ " }\n",\ " button $w.hide -text \"Hide\" -command {\n",\ " set solname [[.occ_dlg.mtre subwidget hlist] info selection]\n",\ " set entityname [[.occ_dlg.mtre subwidget hlist] info data $solname]\n",\ " set spacepos [string first \" \" $entityname]\n",\ " set entitytype [string range $entityname 0 [expr $spacepos-1]]\n",\ " set helpstring [string range $entityname [expr $spacepos+1] [expr [string length $entityname]-1]]\n",\ " set spacepos2 [string first \" \" $helpstring]\n",\ " set entitynumber [string range $helpstring 0 [expr $spacepos2-1]]\n",\ "\n",\ " Ng_OCCCommand hide $entitytype $entitynumber\n",\ " set selectvisual geometry\n",\ " redraw\n",\ " }\n",\ "\n",\ " button $w.swaporientation -text \"Swap orientation\" -command {\n",\ " set solname [[.occ_dlg.mtre subwidget hlist] info selection]\n",\ " set entityname [[.occ_dlg.mtre subwidget hlist] info data $solname]\n",\ " set spacepos [string first \" \" $entityname]\n",\ " set entitytype [string range $entityname 0 [expr $spacepos-1]]\n",\ " set helpstring [string range $entityname [expr $spacepos+1] [expr [string length $entityname]-1]]\n",\ " set spacepos2 [string first \" \" $helpstring]\n",\ " set entitynumber [string range $helpstring 0 [expr $spacepos2-1]]\n",\ "\n",\ " Ng_OCCCommand swaporientation $entitytype $entitynumber\n",\ " set selectvisual geometry\n",\ " redraw\n",\ "\n",\ " [.occ_dlg.mtre subwidget hlist] delete all\n",\ " occdialogbuildtree \n",\ " }\n",\ "\n",\ " button $w.marksingular -text \"Mark/Unmark as singular\" -command {\n",\ " set solname [[.occ_dlg.mtre subwidget hlist] info selection]\n",\ " set entityname [[.occ_dlg.mtre subwidget hlist] info data $solname]\n",\ " set spacepos [string first \" \" $entityname]\n",\ " if { $spacepos != 0 } {\n",\ " set entitytype [string range $entityname 0 [expr $spacepos-1]]\n",\ " set helpstring [string range $entityname [expr $spacepos+1] [expr [string length $entityname]-1]]\n",\ " set spacepos2 [string first \" \" $helpstring]\n",\ " if { $spacepos2 != 0 } {\n",\ " set entitynumber [string range $helpstring 0 [expr $spacepos2-1]]\n",\ " \n",\ " global ismarkedsingular\n",\ " Ng_OCCCommand marksingular $entitytype $entitynumber\n",\ " \n",\ " set hlist [$w.mtre subwidget hlist]\n",\ " \n",\ " set style1 [tixDisplayStyle imagetext -foreground black -background white -selectforeground white -selectbackground blue]\n",\ " set style2 [tixDisplayStyle imagetext -foreground red -background white -selectforeground red -selectbackground blue]\n",\ " \n",\ " if { $ismarkedsingular == 0 } {\n",\ " $hlist entryconfigure $solname -style $style1\n",\ " } {\n",\ " $hlist entryconfigure $solname -style $style2\n",\ " }\n",\ "\n",\ " }\n",\ " }\n",\ "\n",\ "\n",\ " }\n",\ "\n",\ "\n",\ " checkbutton $w.zoomtohighlightedentity -text \"Zoom to highlighted entity\" \\\n",\ " -variable occoptions.zoomtohighlightedentity \\\n",\ " -command {\n",\ " Ng_SetOCCVisParameters\n",\ " if { ${occoptions.zoomtohighlightedentity} == 1} {\n",\ " set selectvisual geometry\n",\ " Ng_OCCCommand redrawstatus 1\n",\ " redraw\n",\ " } {\n",\ " Ng_OCCCommand redrawstatus 0\n",\ " }\n",\ " }\n",\ "\n",\ "\n",\ "\n",\ " frame $w.healing -relief groove -borderwidth 3\n",\ "\n",\ " button $w.healing.checkentities -text \"Analyze geometry\" -command {\n",\ " set irregent [Ng_OCCCommand findsmallentities]\n",\ "\n",\ " set w .occ_dlg\n",\ " set hlist [$w.mtre subwidget hlist]\n",\ " \n",\ " $hlist add ProblematicEntities -text \"Problematic Entities\"\n",\ " $hlist delete offsprings ProblematicEntities\n",\ "\n",\ " set nritems [expr [llength $irregent]]\n",\ " set i [expr 0]\n",\ " while {$i < $nritems} {\n",\ " set entity [lindex $irregent [expr $i]]\n",\ " incr i 1\n",\ " set entityname [lindex $irregent [expr $i]]\n",\ " $hlist add ProblematicEntities/$entity -text $entityname -data $entityname\n",\ " incr i 1\n",\ " }\n",\ " $w.mtre open ProblematicEntities\n",\ " $w.mtre autosetmode\n",\ " }\n",\ "\n",\ " tixControl $w.healing.tolerance -label \"Healing tolerance: \" -integer false \\\n",\ " -variable occoptions.tolerance -min 1e-9 -max 1e6 \\\n",\ " -options {\n",\ " entry.width 6\n",\ " label.width 25\n",\ " label.anchor e\n",\ " } \n",\ "\n",\ " checkbutton $w.healing.fixsmalledges -text \"Fix small edges\" \\\n",\ " -variable occoptions.fixsmalledges\n",\ " \n",\ " checkbutton $w.healing.fixspotstripfaces -text \"Fix spot/strip faces\" \\\n",\ " -variable occoptions.fixspotstripfaces\n",\ " \n",\ " checkbutton $w.healing.sewfaces -text \"Sew faces\" \\\n",\ " -variable occoptions.sewfaces\n",\ " \n",\ " checkbutton $w.healing.makesolids -text \"Make solids\" \\\n",\ " -variable occoptions.makesolids\n",\ " \n",\ " checkbutton $w.healing.splitpartitions -text \"Split partitions\" \\\n",\ " -variable occoptions.splitpartitions\n",\ " \n",\ " button $w.healing.heal -text \"Heal geometry\" -command { \n",\ " .occ_dlg.healing.tolerance invoke\n",\ " Ng_OCCCommand shapehealing\n",\ " redraw \n",\ " [.occ_dlg.mtre subwidget hlist] delete all\n",\ " occdialogbuildtree\n",\ " }\n",\ "\n",\ " pack $w.healing.checkentities\n",\ "\n",\ " pack $w.healing.tolerance $w.healing.fixsmalledges \\\n",\ " $w.healing.fixspotstripfaces $w.healing.sewfaces \\\n",\ " $w.healing.makesolids $w.healing.splitpartitions -anchor w\n",\ "\n",\ " pack $w.healing.heal \n",\ "\n",\ "\n",\ "\n",\ "\n",\ " pack $w.show $w.hide\n",\ "\n",\ " pack $w.zoomtohighlightedentity -anchor w\n",\ " pack $w.swaporientation\n",\ " pack $w.marksingular\n",\ " pack $w.healing -fill x\n",\ " pack $w.cl\n",\ " \n",\ " \n",\ " wm withdraw $w\n",\ " wm geom $w +100+100\n",\ " wm deiconify $w\n",\ " wm title $w \"IGES/STEP Topology Explorer/Doctor\"\n",\ " focus .occ_dlg\n",\ " }\n",\ "}\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "proc printtable { tablevar } {\n",\ " set w newtcltable\n",\ " while {[winfo exists .$w] == 1} {set w 1$w}\n",\ " set w .$w\n",\ " toplevel $w\n",\ " for {set i 0} {$i < [lindex $tablevar 2]} { incr i } {\n",\ " frame $w.col$i\n",\ " for {set j 0} {$j < [lindex $tablevar 1]} { incr j } {\n",\ " frame $w.col$i.row$j\n",\ " message $w.col$i.row$j.txt -aspect 10000000 -text [lindex $tablevar [expr 3+[lindex $tablevar 2]*$j+$i]]\n",\ " pack $w.col$i.row$j.txt\n",\ " pack $w.col$i.row$j -side top\n",\ " }\n",\ " pack $w.col$i -side left\n",\ " }\n",\ " wm withdraw $w\n",\ " wm geom $w +200+100; wm deiconify $w\n",\ " wm title $w [lindex $tablevar 0]\n",\ " focus $w\n",\ "}\n",\ "\n",\ "\n",\ "set latestwarning 0\n",\ "\n",\ "\n",\ "proc printwarning { textvar } {\n",\ " global latestwarning\n",\ " set latestwarning $textvar\n",\ " set w warning\n",\ " while {[winfo exists .$w] == 1} {set w 1$w}\n",\ " set w .$w\n",\ " toplevel $w\n",\ " message $w.mes -aspect 2000 -text \"WARNING:\\n$textvar\"\n",\ " button $w.done -text \"Done\" -command \"destroy $w\"\n",\ " pack $w.mes\n",\ " pack $w.done\n",\ " wm withdraw $w\n",\ " wm deiconify $w\n",\ " wm title $w \"Warning\"\n",\ " focus $w\n",\ "}\n",\ "\n",\ "\n",\ "proc printlatestwarning { } { \n",\ " global latestwarning \n",\ " if {$latestwarning != 0} {printwarning $latestwarning}\n",\ "}\n",\ "\n",\ "\n",\ "proc paralleldialog { } {\n",\ "\n",\ " set w .parallel_dlg\n",\ " \n",\ " if {[winfo exists .parallel_dlg] == 1} {\n",\ " wm withdraw $w\n",\ " wm deiconify $w\n",\ " wm geometry $w =270x100\n",\ "\n",\ " focus $w \n",\ " } {\n",\ "\n",\ " toplevel $w\n",\ " wm geometry $w =270x100\n",\ "\n",\ " set ww $w\n",\ "\n",\ " button $ww.visallb -text \"View All\" -width 20 -command\\\n",\ " { Ng_VisualizeAll; } \n",\ " pack $ww.visallb \n",\ " \n",\ " button $ww.visoneb -text \"View One\" -width 20 -command \\\n",\ " { Ng_VisualizeOne; } \n",\ " pack $ww.visoneb \n",\ " \n",\ " button $ww.overlap -text \"overlap++\" -width 20 -command \\\n",\ " { Ng_IncrOverlap; }\n",\ " \n",\ " pack $ww.overlap \n",\ " \n",\ " wm withdraw $w\n",\ " wm geom $w +100+100\n",\ " wm deiconify $w\n",\ " wm title $w \"Parallel Netgen\"\n",\ " focus .parallel_dlg \n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "proc runtestdialog { } {\n",\ " source $::ngdir/ngtcltk/ngshell.tcl\n",\ " set w .runtest_dlg\n",\ " \n",\ " if {[winfo exists .runtest_dlg] == 1} {\n",\ " wm withdraw $w\n",\ " wm deiconify $w\n",\ "\n",\ " focus $w \n",\ " } {\n",\ " toplevel $w\n",\ "\n",\ " frame $w.in2dframe \n",\ " pack $w.in2dframe\n",\ "\n",\ " set in2dlogfile \"\"\n",\ " tixLabelEntry $w.in2dframe.ent -label \"in2d log-file: console if empty\" \\\n",\ " -labelside top \\\n",\ " -options { \n",\ " entry.textVariable in2dlogfile\n",\ " entry.width 35\n",\ " label.width 25\n",\ " label.anchor w\n",\ " } \n",\ " button $w.in2dframe.btn -text \"Browse\" -command {\n",\ " set types { { \"Log file\" {.log} } }\n",\ " set in2dlogfile [tk_getOpenFile -filetypes $types -initialfile $in2dlogfile]\n",\ " }\n",\ " button $w.in2dframe.test -text \"Test in2d meshing\" -command { ngtest in2d $in2dlogfile }\n",\ "\n",\ " \n",\ " pack $w.in2dframe.test -side left -anchor s -padx 4 -pady 4\n",\ " pack $w.in2dframe.ent -side left -expand yes -fill x -anchor s -padx 4 -pady 4\n",\ " pack $w.in2dframe.btn -side left -anchor s -padx 4 -pady 4\n",\ "\n",\ " \n",\ " frame $w.geoframe \n",\ " pack $w.geoframe\n",\ "\n",\ " set geologfile \"\" \n",\ " tixLabelEntry $w.geoframe.ent -label \"geo log-file: console if empty\" \\\n",\ " -labelside top \\\n",\ " -options { \n",\ " entry.textVariable geologfile\n",\ " entry.width 35\n",\ " label.width 25\n",\ " label.anchor w\n",\ " } \n",\ " button $w.geoframe.btn -text \"Browse\" -command {\n",\ " set types { { \"Log file\" {.log} } }\n",\ " set geologfile [tk_getOpenFile -filetypes $types -initialfile $geologfile]\n",\ " }\n",\ " button $w.geoframe.test -text \"Test geo meshing\" -command { ngtest geo $geologfile }\n",\ "\n",\ " \n",\ " pack $w.geoframe.test -side left -anchor s -padx 4 -pady 4\n",\ " pack $w.geoframe.ent -side left -expand yes -fill x -anchor s -padx 4 -pady 4\n",\ " pack $w.geoframe.btn -side left -anchor s -padx 4 -pady 4\n",\ "\n",\ " frame $w.stlframe \n",\ " pack $w.stlframe\n",\ "\n",\ " set stllogfile \"\"\n",\ " tixLabelEntry $w.stlframe.ent -label \"stl log-file: console if empty\" \\\n",\ " -labelside top \\\n",\ " -options { \n",\ " entry.textVariable stllogfile\n",\ " entry.width 35\n",\ " label.width 25\n",\ " label.anchor w\n",\ " } \n",\ " button $w.stlframe.btn -text \"Browse\" -command {\n",\ " set types { { \"Log file\" {.log} } }\n",\ " set stllogfile [tk_getOpenFile -filetypes $types -initialfile $stllogfile]\n",\ " }\n",\ " button $w.stlframe.test -text \"Test stl meshing\" -command { ngtest stl $stllogfile }\n",\ "\n",\ " \n",\ " pack $w.stlframe.test -side left -anchor s -padx 4 -pady 4\n",\ " pack $w.stlframe.ent -side left -expand yes -fill x -anchor s -padx 4 -pady 4\n",\ " pack $w.stlframe.btn -side left -anchor s -padx 4 -pady 4\n",\ "\n",\ " frame $w.pdeframe \n",\ " pack $w.pdeframe\n",\ "\n",\ " set pdelogfile \"\"\n",\ " tixLabelEntry $w.pdeframe.ent -label \"pde log-file: console if empty\" \\\n",\ " -labelside top \\\n",\ " -options { \n",\ " entry.textVariable pdelogfile\n",\ " entry.width 35\n",\ " label.width 25\n",\ " label.anchor w\n",\ " } \n",\ " button $w.pdeframe.btn -text \"Browse\" -command {\n",\ " set types { { \"Log file\" {.log} } }\n",\ " set pdelogfile [tk_getOpenFile -filetypes $types -initialfile $pdelogfile]\n",\ " }\n",\ " button $w.pdeframe.test -text \"Test ngsolve pde's\" -command { ngtest pde $pdelogfile }\n",\ "\n",\ " \n",\ " pack $w.pdeframe.test -side left -anchor s -padx 4 -pady 4\n",\ " pack $w.pdeframe.ent -side left -expand yes -fill x -anchor s -padx 4 -pady 4\n",\ " pack $w.pdeframe.btn -side left -anchor s -padx 4 -pady 4\n",\ " \n",\ " wm title $w \"Testing\"\n",\ " focus .runtest_dlg \n",\ " }\n",\ "}\n",\ "\n",\ "set oldmousex 0\n",\ "set oldmousey 0\n",\ "if {[catch {togl .ndraw -width 400 -height 300 -rgba true -double true -depth true -privatecmap false -stereo false -indirect false }] } { \n",\ " puts \"no OpenGL\" \n",\ "} {\n",\ " pack .ndraw -expand true -fill both -padx 10 -pady 10\n",\ " bind .ndraw {\n",\ " set oldmousex %x; set oldmousey %y;\n",\ " }\n",\ " bind .ndraw {\n",\ " set oldmousex %x; set oldmousey %y;\n",\ " }\n",\ " bind .ndraw {\n",\ " set oldmousex %x; set oldmousey %y;\n",\ " }\n",\ " bind .ndraw {\n",\ " Ng_MouseMove $oldmousex $oldmousey %x %y $drawmode\n",\ " .ndraw render\n",\ " set oldmousex %x; set oldmousey %y;\n",\ " }\n",\ "\n",\ " bind .ndraw {\n",\ " Ng_MouseDblClick %x %y\n",\ " .ndraw render\n",\ " if { [winfo exists .bcprop_dlg] } { bcpropdialog }\n",\ " if { [winfo exists .fieldlines_dlg] } { fieldlinesdialog }\n",\ " }\n",\ "\n",\ " bind .ndraw {\n",\ " Ng_MouseMove $oldmousex $oldmousey %x %y move\n",\ " .ndraw render\n",\ " set oldmousex %x; set oldmousey %y;\n",\ " }\n",\ "\n",\ " bind .ndraw {\n",\ " Ng_MouseMove $oldmousex $oldmousey %x %y zoom\n",\ " .ndraw render\n",\ " set oldmousex %x; set oldmousey %y;\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "proc popupcheckredraw { vari { x 0 } } {\n",\ " upvar $vari varname\n",\ " if { $varname == 1 } {\n",\ " set varname 0\n",\ " } {\n",\ " Ng_Vis_Set parameters\n",\ " redraw\n",\ " }\n",\ "}\n",\ "proc popupcheckredraw2 { vari boolvar { x 0 } } {\n",\ " upvar $vari varname\n",\ " if { $varname == 1 } {\n",\ " set varname 0\n",\ " } {\n",\ " Ng_SetVisParameters\n",\ " if { $boolvar == 1 } { redraw }\n",\ " Ng_SetVisParameters\n",\ " }\n",\ "}\n",\ "proc popupcheckredraw3 { vari { x 0 } } {\n",\ " upvar $vari varname\n",\ " if { $varname == 1 } {\n",\ " set varname 0\n",\ " } {\n",\ " Ng_Vis_Set parameters\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "proc redraw { {x 0} } {\n",\ " if {[winfo exists .ndraw]} { .ndraw render } \n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "bind . { Ng_MouseMove 0 0 -10 0 rotate; redraw }\n",\ "bind . { Ng_MouseMove 0 0 10 0 rotate; redraw }\n",\ "bind . { Ng_MouseMove 0 0 0 -10 rotate; redraw }\n",\ "bind . { Ng_MouseMove 0 0 0 10 rotate; redraw }\n",\ "bind . { Ng_MouseMove 0 0 -10 0 move; redraw }\n",\ "bind . { Ng_MouseMove 0 0 10 0 move; redraw }\n",\ "bind . { Ng_MouseMove 0 0 0 -10 move; redraw }\n",\ "bind . { Ng_MouseMove 0 0 0 10 move; redraw }\n",\ "bind . { Ng_MouseMove 0 0 0 -10 zoom; redraw }\n",\ "bind . { Ng_MouseMove 0 0 0 10 zoom; redraw }\n",\ "\n",\ "bind all \\\n",\ " {event generate [focus -displayof %W] -delta 120}\n",\ "\n",\ " bind all \\\n",\ " {event generate [focus -displayof %W] -delta -120}\n",\ "\n",\ "bind all { Ng_MouseMove 0 0 0 [expr {%D/-5}] zoom; redraw }\n",\ "\n",\ "proc print_commandline_help { } {\n",\ " \n",\ " puts \"Usage: ng { options }\"\n",\ "\n",\ " puts \"-geofile=filename Input geometry file (alternative: ng filename)\"\n",\ " puts \"-meshfile=filename Output mesh file\"\n",\ " puts \"-verycoarse, -coarse, -moderate, -fine, -veryfine\"\n",\ " puts \" Automatic mesh-size selection\"\n",\ " puts \"-meshsizefile=filename Load mesh-size file with local mesh sizes\"\n",\ " puts \"-meshfiletype={\\\"Neutral Format\\\", ...}\"\n",\ " puts \" Filetype of output file, default is netgen file\"\n",\ " puts \"-batchmode Run Netgen in batchmode\"\n",\ " puts \"-inputmeshfile=filename\"\n",\ " puts \" Input mesh file (batchmode only)\"\n",\ " puts \"-mergefile=filename Merge with mesh file (batchmode only)\"\n",\ " puts \"-refinementfile=filename\"\n",\ " puts \" Use refinementinfo from file (batchmode only)\"\n",\ " puts \"-serversocket=\\#num Start a Netgen server with port \\#num\"\n",\ " puts \"-V Print additional information\"\n",\ " puts \"-testout=filename file for test output\"\n",\ "\n",\ " if { [catch { NGS_GetData } ] == 0 } { \n",\ " puts \"\\nNGSolve parameters:\"\n",\ " puts \"-pdefile=filename Load pde input file\"\n",\ " puts \"-solve Solve pde once\"\n",\ " puts \"-solve=n Solve pde by n adaptive refinement steps\"\n",\ " puts \"-recent Load and solve most recently loaded pde\"\n",\ " }\n",\ "\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "proc set_menu_help { entry helpmsg } {\n",\ " global menuhelps\n",\ " set menuhelps($entry) $helpmsg\n",\ "}\n",\ "\n",\ "proc show_menu_help { entry } {\n",\ " global menuhelps\n",\ "\n",\ "\n",\ " if {[catch {set helptext $menuhelps($entry)}]} {\n",\ " set helptext \"no help available \"\n",\ " } \n",\ "\n",\ " .helpline configure -text $helptext\n",\ " \n",\ " if {[winfo exists .senshelp_dlg]==1} {\n",\ " .senshelp_dlg.text delete 1.0 end\n",\ " .senshelp_dlg.text insert end \"Menu item: $entry\\n\\n\"\n",\ " .senshelp_dlg.text insert end $helptext\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "tixBalloon .balloon -statusbar .helpline\n",\ "\n",\ "proc set_control_help { control helpmsg } {\n",\ " bind $control \"show_control_help {$helpmsg}\"\n",\ " bind $control \"show_control_help {None}\"\n",\ " .balloon bind $control -balloonmsg $helpmsg -statusmsg $helpmsg\n",\ "}\n",\ "\n",\ "proc show_control_help { helpmsg } {\n",\ " .helpline configure -text $helpmsg\n",\ " if {[winfo exists .senshelp_dlg]==1} {\n",\ " .senshelp_dlg.text delete 1.0 end\n",\ " .senshelp_dlg.text insert end $helpmsg\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "proc sensitivehelpdialog { show } {\n",\ "\n",\ " set w .senshelp_dlg\n",\ " \n",\ " if {[winfo exists .senshelp_dlg] == 1} {\n",\ "\n",\ " if { $show == 1 } {\n",\ " wm withdraw .senshelp_dlg\n",\ " wm deiconify $w\n",\ " focus $w \n",\ " } {\n",\ " wm withdraw $w\n",\ " }\n",\ " } {\n",\ " toplevel $w\n",\ "\n",\ " global senshelptext\n",\ "\n",\ " text $w.text -yscrollcommand \"$w.scroll set\" -setgrid true \\\n",\ " -width 40 -height 10 -wrap word\n",\ " scrollbar $w.scroll -command \"$w.text yview\"\n",\ " pack $w.scroll -side right -fill y\n",\ " pack $w.text -expand yes -fill both\n",\ "\n",\ " frame $w.bu\n",\ " pack $w.bu\n",\ " \n",\ " button $w.close -text \"Close\" \\\n",\ " -command { \n",\ " wm withdraw .senshelp_dlg\n",\ " set showsensitivehelp 0\n",\ " }\n",\ " pack $w.close\n",\ " \n",\ " \n",\ " if { $show == 1 } {\n",\ " wm withdraw $w\n",\ " wm geom $w +100+100\n",\ " wm deiconify $w\n",\ " wm title $w \"Help\"\n",\ " focus $w\n",\ " }\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "set_menu_help \"File\" \"In File menu you can load and store geometries, meshes etc.\" \n",\ "\n",\ "set_menu_help \"New Geometry\" \"Deletes current geometry\"\n",\ "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.\"\n",\ "set_menu_help \"Save Geometry\" \"Saves STL Geometry in in either ASCII or binary STL format.\"\n",\ "set_menu_help \"Load Mesh\" \"Loads surface and volume mesh in Netgen internal format.\"\n",\ "set_menu_help \"Save Mesh\" \"Saves surface and volume mesh in Netgen internal format.\"\n",\ "set_menu_help \"Write EPS File\" \"Dumps OpenGL rendering to EPS File.\"\n",\ "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.\"\n",\ "set_menu_help \"Export Mesh\" \"Exports mesh in format defined by Export Filetype.\"\n",\ "set_menu_help \"Export Filetype\" \"Selects file format for exporting mesh. Please have a look into the Netgen User's manual for more information.\"\n",\ "set_menu_help \"Import Mesh\" \"Imports surface or volume mesh in exchange format.\"\n",\ "set_menu_help \"Quit\" \"Quits Netgen\"\n",\ "\n",\ "set_menu_help \"Geometry\" \"Preparing geometries, visualiztion of geometries.\"\n",\ "set_menu_help \"Scan CSG Geometry\" \"Generates surface triangulation for rendering\"\n",\ "set_menu_help \"CSG Options\" \"Sets Options for CSG visualization (bounding box, detail size, number of facets).\"\n",\ "set_menu_help \"CSG Properties\" \"Defines appearence of current CSG geometry (color, visibility, transparency)\"\n",\ "set_menu_help \"STL Doctor\" \"Calls STL Doctor for preprocessing STL geometry files.\"\n",\ "set_menu_help \"STL Info\" \"Retrieves information about current STL geometry.\"\n",\ "\n",\ "set_menu_help \"Mesh\" \"Menu for mesh generation\"\n",\ "set_menu_help \"Generate Mesh\" \"Generates mesh from geometry, same as Button \\\"Generate Mesh\\\"\"\n",\ "set_menu_help \"Stop Meshing\" \"Terminates meshgeneration. It may take a while until meshing terminates, please be patient.\"\n",\ "set_menu_help \"Meshing Options\" \"Set options for mesh generation.\"\n",\ "set_menu_help \"Delete Mesh\" \"Deletes mesh. Not necessary before generation of new mesh.\"\n",\ "set_menu_help \"Delete Vol Mesh\" \"Deletes only volume mesh.\"\n",\ "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.\"\n",\ "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.\"\n",\ "set_menu_help \"Check Volume Mesh\" \"Checks conformity of volume mesh.\"\n",\ "set_menu_help \"Edit Boundary Conditions\" \"Open dialog for setting boundary condition numbers for individual faces.\"\n",\ "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.\"\n",\ "set_menu_help \"Mesh Edges\" \"Meshes edges\"\n",\ "set_menu_help \"Mesh Surface\" \"Generates surface mesh. Includes already surface optimization for some geomtry types.\"\n",\ "set_menu_help \"Optimize Surface\" \"Optimizes surface mesh.\"\n",\ "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).\"\n",\ "set_menu_help \"Mesh Volume\" \"Performs volume meshing. Algorithm is a combination of Delaunay and Rule-based Advancing Front\"\n",\ "set_menu_help \"Optimize Volume\" \"Performs additional volume optimization steps\"\n",\ "set_menu_help \"Smooth Opt Volume\" \"Performs optimization steps by smoothing iterations\"\n",\ "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.\"\n",\ "\n",\ "set_menu_help \"View\" \"Sets viewing options\"\n",\ "set_menu_help \"Zoom all\" \"Zooms scene to show whole object\"\n",\ "set_menu_help \"Center\" \"Defines center of rotation\"\n",\ "set_menu_help \"Viewing Options\" \"Sets viewing options for geometry, mesh, lighting\"\n",\ "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\"\n",\ "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.\"\n",\ "set_menu_help \"Sensitve Help\" \"Shows this help window\"\n",\ "\n",\ "set_menu_help \"Mesh-size\" \"Manipulations of existing mesh\"\n",\ "set_menu_help \"Refine uniform\" \"Refines mesh by splitting elements into eight childs (algorithm of J. Bey)\"\n",\ "set_menu_help \"Second Order\" \"Converts 4 node elements to 10 node elements. Edge-midpoitns are projected to the geometry.\"\n",\ "set_menu_help \"Refinement Dialog\" \"Controls local mesh refinement\"\n",\ "set_menu_help \"Load Meshsize\" \"Loads mesh-size file for local mesh refinement.\"\n",\ "set_menu_help \"MS from Surf Mesh\" \"Defines mesh-size by the surface mesh.\"\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "set f .options_dlg.nb.nbframe.general\n",\ "set_control_help $f.fine \"Controls relative mesh size.\\nThis control affects other mesh-size controls in common\"\n",\ "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\\\"\"\n",\ "set_control_help $f.last \"Last step in mesh generation. If only the surface mesh is required, please set \\\"Last Step\\\" to \\\"Optimize Surface\\\"\"\n",\ "\n",\ "set_control_help .bubar.surfm \"Start mesh generation\"\n",\ "set_control_help .bubar.stopm \"Start mesh generation\"\n",\ "\n",\ "proc help_item { helptext } {p\n",\ " puts $helptext\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "proc show_help { } {\n",\ " \n",\ " set w .help\n",\ " \n",\ " if {[winfo exists .help] == 1} {\n",\ " wm withdraw $w\n",\ " wm deiconif $w\n",\ " focus $w \n",\ " } {\n",\ " \n",\ " toplevel $w\n",\ " \n",\ " frame $w.buttons\n",\ " pack $w.buttons -side bottom -fill x -pady 2m\n",\ " button $w.buttons.done -text Done -command \"destroy $w\"\n",\ " pack $w.buttons.done -side left -expand 1\n",\ "\n",\ " text $w.text -yscrollcommand \"$w.scroll set\" -setgrid true \\\n",\ " -width 60 -height 24 -wrap word\n",\ " scrollbar $w.scroll -command \"$w.text yview\"\n",\ " pack $w.scroll -side right -fill y\n",\ " pack $w.text -expand yes -fill both\n",\ "\n",\ " }\n",\ " $w.text configure -state normal\n",\ " $w.text delete 1.0 end\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "set bold \"-background #43ce80 -relief raised -borderwidth 1\"\n",\ "set normal \"-background {} -relief flat\"\n",\ "\n",\ "\n",\ "proc help_main { } {\n",\ "\n",\ " show_help;\n",\ " set w .help\n",\ " global bold\n",\ " global normal\n",\ "\n",\ "\n",\ " \n",\ " $w.text insert 0.0 \\\n",\ " {NETGEN Help}\n",\ " $w.text insert end \\n\\n\n",\ " $w.text insert end \\\n",\ " {1. General} d1\n",\ " $w.text insert end \\n\\n\n",\ " $w.text insert end \\\n",\ " {2. Menu items } d2\n",\ " $w.text insert end \\n\\n\n",\ "\n",\ " foreach tag {d1 d2} {\n",\ " $w.text tag bind $tag \"$w.text tag configure $tag $bold\"\n",\ " $w.text tag bind $tag \"$w.text tag configure $tag $normal\"\n",\ " }\n",\ " \n",\ " $w.text tag bind d1 <1> { puts \"general\"; help_general }\n",\ " $w.text tag bind d2 <1> { help_menus }\n",\ "\n",\ " $w.text configure -state disabled\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "proc help_general { } {\n",\ "\n",\ " show_help;\n",\ " set w .help\n",\ " global bold\n",\ " global normal\n",\ "\n",\ " puts \"general called\"\n",\ "\n",\ " $w.text insert 0.0 \\\n",\ " {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.}\n",\ "\n",\ " $w.text configure -state disabled\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "proc help_menus { } {\n",\ "\n",\ " show_help;\n",\ " set w .help\n",\ " global bold\n",\ " global normal\n",\ "\n",\ "\n",\ " $w.text insert 0.0 \\\n",\ " {The NETGEN Menu items are}\n",\ " $w.text insert end \\n\\n\n",\ " $w.text insert end \\\n",\ " {1. File} d1\n",\ " $w.text insert end \\n\\n\n",\ " $w.text insert end \\\n",\ " {2. Geometry } d2\n",\ " $w.text insert end \\n\\n\n",\ " $w.text insert end \\\n",\ " {3. Mesh } d3\n",\ " $w.text insert end \\n\\n\n",\ " $w.text insert end \\\n",\ " {4. View } d4\n",\ " $w.text insert end \\n\\n\n",\ " $w.text insert end \\\n",\ " {5. Mesh-size } d5\n",\ " $w.text insert end \\n\\n\n",\ " $w.text insert end \\\n",\ " {6. STL } d6\n",\ "\n",\ " foreach tag {d1 d2 d3 d4 d5 d6} {\n",\ " $w.text tag bind $tag \"$w.text tag configure $tag $bold\"\n",\ " $w.text tag bind $tag \"$w.text tag configure $tag $normal\"\n",\ " }\n",\ " \n",\ " $w.text tag bind d1 <1> {puts \"File menu\"}\n",\ " $w.text tag bind d2 <1> {puts \"Geometry menu\"}\n",\ " $w.text tag bind d3 <1> {puts \"Mesh menu\"}\n",\ " $w.text tag bind d4 <1> {puts \"View menu\"}\n",\ " $w.text tag bind d5 <1> {puts \"Mesh-size menu\"}\n",\ " $w.text tag bind d6 <1> {puts \"STL menu\"}\n",\ "\n",\ " $w.text configure -state disabled\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "Ng_Vis_Set parameters\n",\ "\n",\ "\n",\ "\n",\ "set viscnt 0\n",\ "proc snapshottimer { } {\n",\ " after 2000 { snapshottimer }\n",\ "\n",\ " global viscnt\n",\ " set viscnt [expr $viscnt+1]\n",\ " set s1 0000$viscnt\n",\ " set cnt [string range $s1 [expr [string length $s1]-4] end]\n",\ " set filename \"p$cnt.jpg\"\n",\ "}\n",\ "snapshottimer\n",\ "\n",\ "\n",\ "\n",\ "proc redrawtimer { } {\n",\ " global visoptions.autoredraw\n",\ " global visoptions.autoredrawtime\n",\ "\n",\ " set delay [expr int(${visoptions.autoredrawtime}*1000)]\n",\ " if { ${visoptions.autoredraw} == 1 } { redraw; }\n",\ " after $delay { redrawtimer } \n",\ "}\n",\ "redrawtimer\n",\ "\n",\ "\n",\ "set perstarttime [clock clicks -millisecond]\n",\ "proc redrawperiodic { } {\n",\ " global visoptions.redrawperiodic\n",\ " global perstarttime\n",\ " set curtime [clock clicks -millisecond]\n",\ " Ng_Vis_Set time [expr ($curtime - $perstarttime) / 5]\n",\ " redraw\n",\ " if { ${visoptions.redrawperiodic} == 1 } { after 30 { redrawperiodic } };\n",\ "\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "proc addplotline { identifier datax datay plotinfo {color black}} {\n",\ " set c $identifier.c\n",\ "\n",\ " set xstart [lindex $plotinfo 0]\n",\ " set ystart [lindex $plotinfo 1]\n",\ " set xmin [lindex $plotinfo 2]\n",\ " set ymin [lindex $plotinfo 3]\n",\ " set unitx [lindex $plotinfo 4]\n",\ " set unity [lindex $plotinfo 5]\n",\ " \n",\ " \n",\ " \n",\ " set latestx [expr ([lindex $datax 0]-$xmin)*$unitx + $xstart]\n",\ " set latesty [expr ([lindex $datay 0]-$ymin)*$unity + $ystart]\n",\ " \n",\ " for {set i 1} {$i < [llength $datax]} {incr i} {\n",\ " set xpos [expr ([lindex $datax $i]-$xmin)*$unitx + $xstart]\n",\ " set ypos [expr ([lindex $datay $i]-$ymin)*$unity + $ystart]\n",\ " $c create line $latestx $latesty $xpos $ypos -width 1 -fill $color\n",\ " set latestx $xpos\n",\ " set latesty $ypos\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "proc createlineplot { width height identifier title xmin xmax ymin ymax plotinfo} {\n",\ " set thiswidth $width\n",\ " set thisheight $height\n",\ " if { $thiswidth < 275 } { set thiswidth 275 }\n",\ " if { $thisheight < 225 } { seth thisheight 225 }\n",\ "\n",\ " set w $identifier\n",\ "\n",\ " if {[winfo exists $w] == 1} {\n",\ " \n",\ " wm withdraw $w\n",\ " wm deiconify $w\n",\ " focus $w \n",\ " } {\n",\ " toplevel $w\n",\ " \n",\ " set c $w.c\n",\ " \n",\ " canvas $c -relief raised -width $thiswidth -height $thisheight\n",\ " pack $w.c -side top -fill x\n",\ " \n",\ " set titleFont {Helvetica 18}\n",\ " set smallFont {Helvetica 12}\n",\ "\n",\ " set xstart 100\n",\ " set xend [expr $thiswidth-75]\n",\ " set ystart [expr $thisheight-75]\n",\ " set yend 75\n",\ "\n",\ " $c create line $xstart $ystart $xstart $yend -width 2\n",\ " $c create line $xstart $ystart $xend $ystart -width 2\n",\ "\n",\ " \n",\ "\n",\ " \n",\ " set unitx [expr double($xend-$xstart)/($xmax-$xmin)]\n",\ " set unity [expr double($yend-$ystart)/($ymax-$ymin)]\n",\ "\n",\ " for {set i 0} {$i <= 1} {set i [expr $i+0.2]} {\n",\ " $c create line [expr $xstart+$i*($xend-$xstart)] [expr $ystart] [expr $xstart+$i*($xend-$xstart)] [expr $ystart+5] -width 2\n",\ " $c create text [expr $xstart+$i*($xend-$xstart)] [expr $ystart+7] -anchor n -font $smallFont \\\n",\ " -text [format \"%.3g\" [expr $xmin+$i*($xmax-$xmin)]]\n",\ " $c create line [expr $xstart] [expr $ystart+$i*($yend-$ystart)] [expr $xstart-7] [expr $ystart+$i*($yend-$ystart)] -width 2\n",\ " $c create text [expr $xstart-9] [expr $ystart+$i*($yend-$ystart)] -anchor e -font $smallFont \\\n",\ " -text [format \"%.3g\" [expr $ymin+$i*($ymax-$ymin)]]\n",\ " }\n",\ "\n",\ " upvar $plotinfo ploti\n",\ "\n",\ " set ploti \"$xstart $ystart $xmin $ymin $unitx $unity\"\n",\ "\n",\ " \n",\ " button $w.close -text \"Close\" -command \"destroy $w\"\n",\ " pack $w.close\n",\ "\n",\ " wm withdraw $w\n",\ " wm geom $w +100+100\n",\ " wm deiconify $w\n",\ " wm title $w $title\n",\ " focus $w\n",\ "\n",\ " }\n",\ "\n",\ "}\n",\ "\n",\ "\n",\ "proc getlineplotdata { datax datay xmini xmaxi ymini ymaxi} {\n",\ "\n",\ " upvar $datax datx\n",\ " upvar $datay daty\n",\ " \n",\ " upvar $xmini xmin\n",\ " upvar $xmaxi xmax\n",\ " upvar $ymini ymin\n",\ " upvar $ymaxi ymax\n",\ "\n",\ " global visoptions.lineplotusingx\n",\ " global visoptions.lineplotusingy\n",\ " global visoptions.lineplotsource\n",\ " global visoptions.lineplotfile\n",\ "\n",\ " set datx \"\"\n",\ " set daty \"\"\n",\ "\n",\ " set xmin 1e20\n",\ " set xmax -1e20\n",\ " set ymin 1e20\n",\ " set ymax -1e20\n",\ " \n",\ "\n",\ " if {${visoptions.lineplotsource} == \"file\"} {\n",\ " set fileId [open ${visoptions.lineplotfile} r]\n",\ " set line \"\"\n",\ " \n",\ " while {[gets $fileId line] >= 0} {\n",\ " if { [string index [lindex $line 0] 0] != \"\\#\" } {\n",\ " if { ${visoptions.lineplotusingx} < [llength $line] } {\n",\ " lappend datx [lindex $line ${visoptions.lineplotusingx}]\n",\ " \n",\ " if { [lindex $datx end] < $xmin } {set xmin [lindex $datx end]}\n",\ " if { [lindex $datx end] > $xmax } {set xmax [lindex $datx end]}\n",\ " } {\n",\ " lappend datx 0\n",\ " }\n",\ " if { ${visoptions.lineplotusingy} < [llength $line] } {\n",\ " lappend daty [lindex $line ${visoptions.lineplotusingy}]\n",\ "\n",\ " if { [lindex $daty end] < $ymin } {set ymin [lindex $daty end]}\n",\ " if { [lindex $daty end] > $ymax } {set ymax [lindex $daty end]}\n",\ " } {\n",\ " lappend daty 0\n",\ " }\n",\ " }\n",\ " \n",\ " }\n",\ " close $fileId\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "proc lineplotdialog { } {\n",\ "\n",\ " set w .lineplot_dlg\n",\ " \n",\ " if {[winfo exists .lineplot_dlg] == 1} {\n",\ " wm withdraw $w\n",\ " wm deiconify $w\n",\ " focus $w \n",\ " } {\n",\ " \n",\ " toplevel $w\n",\ " \n",\ " frame $w.filesettings -relief groove -borderwidth 3\n",\ " frame $w.filesettings.title\n",\ " radiobutton $w.filesettings.title.choose -variable visoptions.lineplotsource \\\n",\ " -value file -text \"Data from File\"\n",\ "\n",\ " pack $w.filesettings.title.choose -side left\n",\ "\n",\ " pack $w.filesettings.title\n",\ "\n",\ " \n",\ " global visoptions.lineplotselectedeval\n",\ " global visoptions.lineplotfile\n",\ " global visoptions.evaluatefilenames\n",\ " global visoptions.evaluatefiledescriptions\n",\ "\n",\ " set evdata [NGS_GetData evaluatefiles]\n",\ " set visoptions.evaluatefilenames none\n",\ " set visoptions.evaluatefiledescriptions none\n",\ " for {set i 0} {[expr $i+1] < [llength $evdata]} {incr i 2} {\n",\ " lappend visoptions.evaluatefilenames [lindex $evdata $i]\n",\ " lappend visoptions.evaluatefiledescriptions [lindex $evdata [expr $i+1]] \n",\ " }\n",\ " \n",\ "\n",\ " tixOptionMenu $w.filesettings.latestevals -label \"Use Evaluate Results: \" \\\n",\ " -options {\n",\ " label.width 25\n",\ " label.anchor e\n",\ " menubutton.width 40\n",\ " } \n",\ " \n",\ " for {set i 0} {$i < [llength ${visoptions.evaluatefilenames}]} {incr i} {\n",\ " $w.filesettings.latestevals add command $i \\\n",\ " -label \"[lindex ${visoptions.evaluatefiledescriptions} $i] ([lindex ${visoptions.evaluatefilenames} $i])\"\n",\ " }\n",\ " $w.filesettings.latestevals config -variable visoptions.lineplotselectedeval\n",\ "\n",\ " pack $w.filesettings.latestevals\n",\ " \n",\ " frame $w.filesettings.sfn\n",\ "\n",\ " button $w.filesettings.sfn.bb -text \"Browse\" \\\n",\ " -command { set visoptions.lineplotfile [tk_getOpenFile] }\n",\ "\n",\ " \n",\ " entry $w.filesettings.sfn.fn -width 50 -relief sunken \\\n",\ " -textvariable visoptions.lineplotfile\n",\ "\n",\ " pack $w.filesettings.sfn.bb $w.filesettings.sfn.fn -side left\n",\ "\n",\ " pack $w.filesettings.sfn\n",\ "\n",\ " button $w.filesettings.refresh -text \"Refresh\" -command {\n",\ " if { ${visoptions.lineplotselectedeval} != 0} {\n",\ " set visoptions.lineplotfile [lindex ${visoptions.evaluatefilenames} ${visoptions.lineplotselectedeval}]\n",\ " }\n",\ " \n",\ " set saveusingx ${visoptions.lineplotusingx}\n",\ " set saveusingy ${visoptions.lineplotusingy}\n",\ " \n",\ "\n",\ " \n",\ " for { set i 0 } { $i < [llength ${visoptions.lineplotdatadescr}] } { incr i } {\n",\ " ${visoptions.lineplotxcoordselector} delete $i\n",\ " }\n",\ " for { set i 0 } { $i < [llength ${visoptions.lineplotdatadescr}] } { incr i } {\n",\ " ${visoptions.lineplotycoordselector} delete $i\n",\ " }\n",\ "\n",\ " \n",\ " set fileId [open ${visoptions.lineplotfile} r]\n",\ " set line \"\"\n",\ " gets $fileId line\n",\ " close $fileId\n",\ " if { [lindex $line 0] == \"\\#nglineplotinfo\" } {\n",\ " set visoptions.lineplotdatadescr [lrange $line 1 end] \n",\ " } {\n",\ " set visoptions.lineplotdatadescr \"\"\n",\ " for { set i 0 } { $i < [llength $line] } { incr i } {\n",\ " lappend visoptions.lineplotdatadescr \"data[expr $i+1]\"\n",\ " }\n",\ " }\n",\ "\n",\ " for { set i 0 } { $i < [llength ${visoptions.lineplotdatadescr}] } { incr i } {\n",\ " ${visoptions.lineplotxcoordselector} add command $i -label [lindex ${visoptions.lineplotdatadescr} $i]\n",\ " }\n",\ " for { set i 0 } { $i < [llength ${visoptions.lineplotdatadescr}] } { incr i } {\n",\ " ${visoptions.lineplotycoordselector} add command $i -label [lindex ${visoptions.lineplotdatadescr} $i]\n",\ " }\n",\ "\n",\ " if { $saveusingx < [llength ${visoptions.lineplotdatadescr}] } {\n",\ " set visoptions.lineplotusingx $saveusingx\n",\ " } {\n",\ " set visoptions.lineplotusingx 0\n",\ " }\n",\ " if { $saveusingy < [llength ${visoptions.lineplotdatadescr}] } {\n",\ " set visoptions.lineplotusingy $saveusingy\n",\ " } {\n",\ " set visoptions.lineplotusingy 1\n",\ " } \n",\ " }\n",\ "\n",\ " pack $w.filesettings.refresh\n",\ "\n",\ "\n",\ " frame $w.filesettings.using\n",\ "\n",\ " global visoptions.lineplotdatadescr\n",\ " \n",\ " tixOptionMenu $w.filesettings.using.xco -label \"X-Coord:\"\\\n",\ " -options {\n",\ " label.width 8\n",\ " label.anchor e\n",\ " menubutton.width 15\n",\ " } \n",\ " for { set i 0 } { $i < [llength ${visoptions.lineplotdatadescr}] } { incr i } {\n",\ " $w.filesettings.using.xco add command $i -label [lindex ${visoptions.lineplotdatadescr} $i]\n",\ " }\n",\ " $w.filesettings.using.xco config -variable visoptions.lineplotusingx\n",\ " \n",\ " tixOptionMenu $w.filesettings.using.yco -label \"Y-Coord:\"\\\n",\ " -options {\n",\ " label.width 8\n",\ " label.anchor e\n",\ " menubutton.width 15\n",\ " } \n",\ " for { set i 0 } { $i < [llength ${visoptions.lineplotdatadescr}] } { incr i } {\n",\ " $w.filesettings.using.yco add command $i -label [lindex ${visoptions.lineplotdatadescr} $i]\n",\ " }\n",\ " $w.filesettings.using.yco config -variable visoptions.lineplotusingy\n",\ "\n",\ " global visoptions.lineplotxcoordselector\n",\ " global visoptions.lineplotycoordselector\n",\ " set visoptions.lineplotxcoordselector $w.filesettings.using.xco\n",\ " set visoptions.lineplotycoordselector $w.filesettings.using.yco\n",\ " \n",\ "\n",\ " pack $w.filesettings.using.xco $w.filesettings.using.yco -side left\n",\ " pack $w.filesettings.using\n",\ "\n",\ " pack $w.filesettings -fill x -ipady 3\n",\ " \n",\ " frame $w.settings -relief groove -borderwidth 3\n",\ " label $w.settings.title -text \"\\nSettings\\n\"\n",\ " pack $w.settings.title\n",\ "\n",\ " frame $w.settings.minmax \n",\ " checkbutton $w.settings.minmax.autoscale -text \"Autoscale\" -variable visoptions.lineplotautoscale\n",\ " tixControl $w.settings.minmax.xmin -label \"Min. x: \" \\\n",\ " -integer false -variable visoptions.lineplotxmin \\\n",\ " -options {\n",\ " entry.width 6\n",\ " label.width 8\n",\ " label.anchor e\n",\ " } \n",\ " tixControl $w.settings.minmax.xmax -label \"Max. x: \" \\\n",\ " -integer false -variable visoptions.lineplotxmax \\\n",\ " -options {\n",\ " entry.width 6\n",\ " label.width 8\n",\ " label.anchor e\n",\ " } \n",\ " tixControl $w.settings.minmax.ymin -label \"Min. y: \" \\\n",\ " -integer false -variable visoptions.lineplotymin \\\n",\ " -options {\n",\ " entry.width 6\n",\ " label.width 8\n",\ " label.anchor e\n",\ " } \n",\ " tixControl $w.settings.minmax.ymax -label \"Max. y: \" \\\n",\ " -integer false -variable visoptions.lineplotymax \\\n",\ " -options {\n",\ " entry.width 6\n",\ " label.width 8\n",\ " label.anchor e\n",\ " } \n",\ " \n",\ "\n",\ " pack $w.settings.minmax.autoscale $w.settings.minmax.xmin $w.settings.minmax.xmax \\\n",\ " $w.settings.minmax.ymin $w.settings.minmax.ymax -side left\n",\ "\n",\ " pack $w.settings.minmax\n",\ "\n",\ " \n",\ " label $w.settings.empty1 -text \"\"\n",\ " pack $w.settings.empty1\n",\ "\n",\ " frame $w.settings.plotsize\n",\ "\n",\ " tixControl $w.settings.plotsize.xsize -label \"Plotsize x: \"\\\n",\ " -integer true -variable visoptions.lineplotsizex \\\n",\ " -options {\n",\ " entry.width 6\n",\ " label.width 13\n",\ " label.anchor e\n",\ " } \n",\ " tixControl $w.settings.plotsize.ysize -label \"y: \"\\\n",\ " -integer true -variable visoptions.lineplotsizey \\\n",\ " -options {\n",\ " entry.width 6\n",\ " label.width 3\n",\ " label.anchor e\n",\ " } \n",\ "\n",\ " pack $w.settings.plotsize.xsize $w.settings.plotsize.ysize -side left\n",\ "\n",\ " pack $w.settings.plotsize\n",\ "\n",\ " label $w.settings.empty2 -text \"\"\n",\ " pack $w.settings.empty2\n",\ " \n",\ "\n",\ " tixOptionMenu $w.settings.color -label \"Linecolor: \" \\\n",\ " -options {\n",\ " label.width 19\n",\ " label.anchor e\n",\ " menubutton.width 15\n",\ " } \n",\ " foreach step { red black blue green yellow } {\n",\ " $w.settings.color add command $step -label $step\n",\ " }\n",\ " $w.settings.color config -variable visoptions.lineplotcolor\n",\ "\n",\ " pack $w.settings.color\n",\ "\n",\ "\n",\ " pack $w.settings\n",\ "\n",\ " set datax \"\"\n",\ " set datay \"\"\n",\ " set xmin 0\n",\ " set xmax 0\n",\ " set ymin 0\n",\ " set ymax 0\n",\ "\n",\ " frame $w.plots -relief groove -borderwidth 3\n",\ "\n",\ " tixOptionMenu $w.plots.selplot -label \"Selected Plot: \" \\\n",\ " -options {\n",\ " label.width 19\n",\ " label.anchor e\n",\ " menubutton.width 15\n",\ " } \n",\ " $w.plots.selplot add command none -label \"None\"\n",\ "\n",\ " $w.plots.selplot config -variable visoptions.lineplotselected\n",\ "\n",\ " global visoptions.lineplotselector\n",\ " set visoptions.lineplotselector $w.plots.selplot\n",\ "\n",\ " \n",\ "\n",\ " button $w.plots.new -text \"Generate New Plot\" -command {\n",\ " if { ${visoptions.lineplotselectedeval} != 0} {\n",\ " set visoptions.lineplotfile [lindex ${visoptions.evaluatefilenames} ${visoptions.lineplotselectedeval}]\n",\ " }\n",\ "\n",\ " getlineplotdata datax datay xmin xmax ymin ymax\n",\ "\n",\ " puts stdout \"xmin $xmin xmax $xmax ymin $ymin ymax $ymax\"\n",\ "\n",\ " global visoptions.lineplotautoscale\n",\ "\n",\ " if {! ${visoptions.lineplotautoscale}} {\n",\ " puts \"using set min/max values\"\n",\ " set xmin ${visoptions.lineplotxmin}\n",\ " set xmax ${visoptions.lineplotxmax}\n",\ " set ymin ${visoptions.lineplotymin}\n",\ " set ymax ${visoptions.lineplotymax}\n",\ " }\n",\ " \n",\ " incr visoptions.lineplotcurrentnum\n",\ " \n",\ " set ident .newplot${visoptions.lineplotcurrentnum}\n",\ " set plotinfo \"\"\n",\ " \n",\ " createlineplot ${visoptions.lineplotsizex} ${visoptions.lineplotsizey} \\\n",\ " $ident \"Lineplot ${visoptions.lineplotcurrentnum}\" \\\n",\ " $xmin $xmax $ymin $ymax plotinfo\n",\ " \n",\ " lappend visoptions.lineplotinfos $plotinfo\n",\ "\n",\ " \n",\ " ${visoptions.lineplotselector} add command ${visoptions.lineplotcurrentnum} -label \"Lineplot ${visoptions.lineplotcurrentnum}\"\n",\ "\n",\ " addplotline $ident $datax $datay $plotinfo ${visoptions.lineplotcolor}\n",\ " }\n",\ " \n",\ " button $w.plots.addto -text \"Add to Selected Plot\" -command {\n",\ " if { ${visoptions.lineplotselectedeval} != 0} {\n",\ " set visoptions.lineplotfile [lindex ${visoptions.evaluatefilenames} ${visoptions.lineplotselectedeval}]\n",\ " }\n",\ "\n",\ " if { ${visoptions.lineplotselected} != \"none\" } {\n",\ "\n",\ " getlineplotdata datax datay xmin xmax ymin ymax\n",\ "\n",\ " set ident .newplot${visoptions.lineplotselected}\n",\ " set plotinfo [lindex ${visoptions.lineplotinfos} ${visoptions.lineplotselected}]\n",\ "\n",\ " addplotline $ident $datax $datay $plotinfo ${visoptions.lineplotcolor}\n",\ " }\n",\ " }\n",\ " \n",\ " \n",\ " \n",\ " pack $w.plots.new $w.plots.addto $w.plots.selplot\n",\ " \n",\ " \n",\ " pack $w.plots -fill x -ipady 3\n",\ " \n",\ "\n",\ "\n",\ " button $w.close -text \"Close\" -command \"destroy $w\"\n",\ " pack $w.close\n",\ " \n",\ " wm withdraw $w\n",\ " wm geom $w +200+100\n",\ " wm deiconify $w\n",\ " wm title $w \"2D Lineplots\"\n",\ "\n",\ " focus $w\n",\ " \n",\ "\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "set fieldlinesdialog_pop1 0\n",\ "\n",\ "\n",\ "proc fieldlinesdialog { } {\n",\ " \n",\ " set w .fieldlines_dlg\n",\ "\n",\ " global fieldlinesdialog_pop1\n",\ " set fieldlinesdialog_pop1 1\n",\ "\n",\ " \n",\ " if {[winfo exists .fieldlines_dlg] == 1} {\n",\ " wm withdraw $w\n",\ " wm deiconify $w\n",\ " focus $w \n",\ " } {\n",\ " \n",\ " toplevel $w\n",\ "\n",\ " tixNoteBook $w.nb -ipadx 6 -ipady 6\n",\ "\n",\ " $w.nb add draw -label \"Draw\"\n",\ " $w.nb add settings -label \"Settings\"\n",\ "\n",\ " pack $w.nb -expand yes -fill both -padx 5 -pady 5 -side top\n",\ "\n",\ "\n",\ " \n",\ " set f [$w.nb subwidget draw]\n",\ " \n",\ "\n",\ " frame $f.general\n",\ "\n",\ " \n",\ " checkbutton $f.general.enable -text \"Enable Fieldlines\" \\\n",\ " -variable visoptions.drawfieldlines \\\n",\ " -command { \n",\ " Ng_Vis_Set parameters; \n",\ " redraw \n",\ " }\n",\ " tixControl $f.general.num -label \"Num: \" -integer true \\\n",\ " -variable visoptions.numfieldlines \\\n",\ " -command { Ng_Vis_Set parameters; redraw } \\\n",\ " -options {\n",\ " entry.width 6\n",\ " label.width 12\n",\ " label.anchor e\n",\ " } \n",\ "\n",\ " \n",\ " pack $f.general.enable $f.general.num -side left\n",\ "\n",\ " pack $f.general\n",\ "\n",\ " label $f.labe0 -text \" \"\n",\ "\n",\ " pack $f.labe0\n",\ "\n",\ " frame $f.general1\n",\ " \n",\ " checkbutton $f.general1.randomstart -text \"Field dependent density \" \\\n",\ " -variable visoptions.fieldlinesrandomstart \\\n",\ " -command { Ng_Vis_Set parameters; redraw}\n",\ "\n",\ " \n",\ " checkbutton $f.general1.redrawperiodic -text \"Animate periodic\" \\\n",\ " -variable visoptions.redrawperiodic \\\n",\ " -command { \n",\ " redrawperiodic\n",\ " Ng_Vis_Set parameters; \n",\ " redraw \n",\ " }\n",\ "\n",\ " pack $f.general1.randomstart $f.general1.redrawperiodic -side left\n",\ "\n",\ " pack $f.general1\n",\ "\n",\ "\n",\ "\n",\ " label $f.lab0 -text \" \"\n",\ "\n",\ " pack $f.lab0\n",\ "\n",\ "\n",\ " \n",\ " tixOptionMenu $f.vecfun -label \"Vector Function: \" \\\n",\ " -options {\n",\ " label.width 18\n",\ " label.anchor e\n",\ " menubutton.width 12\n",\ " }\n",\ " $f.vecfun add command none -label None \n",\ " for { set i 1 } { $i <= [Ng_Vis_Field getnfieldnames] } { incr i } {\n",\ " set fname [Ng_Vis_Field getfieldname $i]\n",\ " set fcomp [Ng_Vis_Field getfieldcomponents $i]\n",\ " set iscomplex [Ng_Vis_Field iscomplex $i]\n",\ " set sdim [Ng_Vis_Field getdimension]\n",\ " if { $iscomplex == 1 } { set fcomp [expr $fcomp / 2] }\n",\ " if { ($fcomp == $sdim) || ($fcomp == 3) } {\n",\ " $f.vecfun add command $fname -label $fname\n",\ " } \n",\ " }\n",\ " $f.vecfun configure -variable visoptions.fieldlinesvecfunction\n",\ " $f.vecfun configure -command { Ng_Vis_Set parameters; redraw }\n",\ "\n",\ " pack $f.vecfun\n",\ " \n",\ "\n",\ "\n",\ " label $f.lab00 -text \" \"\n",\ "\n",\ " pack $f.lab00\n",\ "\n",\ " frame $f.phasesettings\n",\ "\n",\ " checkbutton $f.phasesettings.onephase -text \"Fix Phase\" -variable visoptions.fieldlinesonlyonephase\n",\ " scale $f.phasesettings.phase -orient horizontal -length 300 -from 0 -to 360 \\\n",\ " -label \"phi\" \\\n",\ " -resolution 1 \\\n",\ " -variable visoptions.fieldlinesphase \\\n",\ " -command { popupcheckredraw3 fieldlinesdialog_pop1 }\n",\ "\n",\ " pack $f.phasesettings.onephase $f.phasesettings.phase -side left\n",\ " \n",\ " pack $f.phasesettings\n",\ "\n",\ "\n",\ "\n",\ " label $f.lab1 -text \" \"\n",\ "\n",\ " pack $f.lab1\n",\ "\n",\ "\n",\ " \n",\ " frame $f.boxsettings -relief groove -borderwidth 3\n",\ " frame $f.boxsettings.title\n",\ " radiobutton $f.boxsettings.title.choose -variable visoptions.fieldlinesstartarea \\\n",\ " -value box -text \"Startpoints in Box\"\n",\ "\n",\ " pack $f.boxsettings.title.choose -side left\n",\ "\n",\ " pack $f.boxsettings.title\n",\ "\n",\ " frame $f.boxsettings.points\n",\ "\n",\ " label $f.boxsettings.points.lab2 -text \"Pmin\";\n",\ " entry $f.boxsettings.points.ent1x -width 8 -relief sunken \\\n",\ " -textvariable visoptions.fieldlinesstartareap1x\n",\ " entry $f.boxsettings.points.ent1y -width 8 -relief sunken \\\n",\ " -textvariable visoptions.fieldlinesstartareap1y\n",\ " entry $f.boxsettings.points.ent1z -width 8 -relief sunken \\\n",\ " -textvariable visoptions.fieldlinesstartareap1z\n",\ " label $f.boxsettings.points.lab3 -text \" Pmax\";\n",\ " entry $f.boxsettings.points.ent2x -width 8 -relief sunken \\\n",\ " -textvariable visoptions.fieldlinesstartareap2x\n",\ " entry $f.boxsettings.points.ent2y -width 8 -relief sunken \\\n",\ " -textvariable visoptions.fieldlinesstartareap2y\n",\ " entry $f.boxsettings.points.ent2z -width 8 -relief sunken \\\n",\ " -textvariable visoptions.fieldlinesstartareap2z\n",\ " \n",\ " pack $f.boxsettings.points\n",\ " pack $f.boxsettings.points.lab2 $f.boxsettings.points.ent1x $f.boxsettings.points.ent1y $f.boxsettings.points.ent1z -side left\n",\ " pack $f.boxsettings.points.lab3 $f.boxsettings.points.ent2x $f.boxsettings.points.ent2y $f.boxsettings.points.ent2z -side left\n",\ "\n",\ " button $f.boxsettings.settobb -text \"Bounding Box\" -command {\n",\ " set bbox [Ng_MeshInfo bbox]\n",\ " set visoptions.fieldlinesstartareap1x [lindex $bbox 0]\n",\ " set visoptions.fieldlinesstartareap2x [lindex $bbox 1]\n",\ " set visoptions.fieldlinesstartareap1y [lindex $bbox 2]\n",\ " set visoptions.fieldlinesstartareap2y [lindex $bbox 3]\n",\ " set visoptions.fieldlinesstartareap1z [lindex $bbox 4]\n",\ " set visoptions.fieldlinesstartareap2z [lindex $bbox 5]\n",\ " }\n",\ "\n",\ " pack $f.boxsettings.settobb\n",\ " \n",\ " \n",\ " pack $f.boxsettings -fill x -ipady 3\n",\ "\n",\ "\n",\ " frame $f.facesettings -relief groove -borderwidth 3\n",\ " frame $f.facesettings.title\n",\ " radiobutton $f.facesettings.title.choose -variable visoptions.fieldlinesstartarea \\\n",\ " -value face -text \"Startpoints on Face\"\n",\ "\n",\ " pack $f.facesettings.title.choose -side left\n",\ "\n",\ " pack $f.facesettings.title\n",\ " \n",\ " frame $f.facesettings.index\n",\ " label $f.facesettings.index.lab -text \"face index:\"\n",\ " label $f.facesettings.index.ent -text 1 -padx 4\n",\ "\n",\ " pack $f.facesettings.index.lab $f.facesettings.index.ent -side left\n",\ "\n",\ " pack $f.facesettings.index\n",\ " \n",\ " pack $f.facesettings -fill x -ipady 3\n",\ "\n",\ "\n",\ " global visoptions.fieldlinesfilename\n",\ "\n",\ " frame $f.filesettings -relief groove -borderwidth 3\n",\ " frame $f.filesettings.title\n",\ " radiobutton $f.filesettings.title.choose -variable visoptions.fieldlinesstartarea \\\n",\ " -value file -text \"Startpoints from File\"\n",\ "\n",\ " pack $f.filesettings.title.choose -side left\n",\ "\n",\ " pack $f.filesettings.title\n",\ "\n",\ " frame $f.filesettings.sfn\n",\ "\n",\ " button $f.filesettings.sfn.bb -text \"Browse\" \\\n",\ " -command {\n",\ " set types {\n",\ " { \"Netgen Fieldlines\" {.nef} }\n",\ " }\n",\ " set visoptions.fieldlinesfilename [tk_getOpenFile -filetypes $types -defaultextension \".nef\"]\n",\ " }\n",\ "\n",\ " \n",\ " entry $f.filesettings.sfn.fn -width 50 -relief sunken \\\n",\ " -textvariable visoptions.fieldlinesfilename\n",\ "\n",\ " pack $f.filesettings.sfn.bb $f.filesettings.sfn.fn -side left\n",\ "\n",\ " pack $f.filesettings.sfn\n",\ "\n",\ " pack $f.filesettings -fill x -ipady 3\n",\ " \n",\ "\n",\ "\n",\ " \n",\ " \n",\ " set g [$w.nb subwidget settings]\n",\ "\n",\ " frame $g.linesettings -relief groove -borderwidth 3\n",\ " label $g.linesettings.title -text \"\\nLine Settings\\n\"\n",\ " tixControl $g.linesettings.length -label \"rel. Length: \" -integer false \\\n",\ " -variable visoptions.fieldlineslength -min 0.00001 -max 10000 -step 0.1 \\\n",\ " -options {\n",\ " entry.width 6\n",\ " label.width 25\n",\ " label.anchor e\n",\ " }\n",\ "\n",\ " tixControl $g.linesettings.maxpoints -label \"max. Points: \" -integer true \\\n",\ " -variable visoptions.fieldlinesmaxpoints -min 0 -max 10000 -step 1 \\\n",\ " -options {\n",\ " entry.width 6\n",\ " label.width 25\n",\ " label.anchor e\n",\ " }\n",\ "\n",\ " tixControl $g.linesettings.thick -label \"rel. Thickness: \" -integer false \\\n",\ " -variable visoptions.fieldlinesthickness -min 1e-10 -max 0.5 -step 0.001 \\\n",\ " -options {\n",\ " entry.width 6\n",\ " label.width 25\n",\ " label.anchor e\n",\ " }\n",\ "\n",\ " pack $g.linesettings.title $g.linesettings.length $g.linesettings.maxpoints $g.linesettings.thick\n",\ "\n",\ " pack $g.linesettings -fill x -ipady 3\n",\ "\n",\ "\n",\ " \n",\ "\n",\ "\n",\ " global visoptions.fieldlinestolerance\n",\ "\n",\ " frame $g.odesettings -relief groove -borderwidth 3\n",\ " label $g.odesettings.title -text \"\\nODE Settings\\n\"\n",\ " tixControl $g.odesettings.tol -label \"rel. Tolerance: \" -integer false \\\n",\ " -variable visoptions.fieldlinestolerance -min 0.00001 -max 1 -step 0.01 \\\n",\ " -options {\n",\ " entry.width 6\n",\ " label.width 25\n",\ " label.anchor e\n",\ " } \n",\ "\n",\ "\n",\ " tixOptionMenu $g.odesettings.rktype -label \"RK-Type \" \\\n",\ " -options {\n",\ " label.width 20\n",\ " label.anchor e\n",\ " menubutton.width 25\n",\ " }\n",\ " $g.odesettings.rktype add command euler -label \"Euler, order 1\"\n",\ " $g.odesettings.rktype add command eulercauchy -label \"Euler-Cauchy, order 2\"\n",\ " $g.odesettings.rktype add command simpson -label \"Simpson, order 3\"\n",\ " $g.odesettings.rktype add command crungekutta -label \"classical Runge-Kutta, order 4\"\n",\ " $g.odesettings.rktype configure -variable visoptions.fieldlinesrktype\n",\ " $g.odesettings.rktype configure -command { Ng_Vis_Set parameters; redraw }\n",\ " \n",\ " pack $g.odesettings.title $g.odesettings.tol $g.odesettings.rktype\n",\ "\n",\ " pack $g.odesettings -fill x -ipady 3\n",\ "\n",\ "\n",\ "\n",\ " \n",\ "\n",\ " frame $w.bu\n",\ " pack $w.bu \n",\ "\n",\ " button $w.bu.calc -text \"Build Fieldlines\" -command { \n",\ " if { ${visoptions.fieldlinesvecfunction} == \"none\" } {\n",\ " bgerror \"Please select the vector function first!\"\n",\ " } {\n",\ " set visoptions.drawfieldlines 1\n",\ " Ng_Vis_Set parameters\n",\ " Ng_BuildFieldLines\n",\ " redraw \n",\ " }\n",\ " }\n",\ "\n",\ " button $w.bu.help -text \"Help\" -command {\n",\ " if {[winfo exists .fieldlines_help] == 1} {\n",\ " wm withdraw .fieldlines_help\n",\ " wm deiconify .fieldlines_help\n",\ " focus .fieldlines_help\n",\ " } {\n",\ " toplevel .fieldlines_help\n",\ "\n",\ " tixScrolledText .fieldlines_help.ht -scrollbar y\n",\ " set text [.fieldlines_help.ht subwidget text]\n",\ "\n",\ " $text configure -setgrid true -wrap word \n",\ "\n",\ " $text tag configure bold -font *-*-bold-*-*-*-*\n",\ "\n",\ " \n",\ " $text insert end \\\n",\ " \"Draw menu\\n \\n\" bold\n",\ " $text insert end \\\n",\ " \"Enable Fieldlines\\n To turn on and off the calculated fieldlines. (Has to be turned on to start the calculation)\\n\"\n",\ " $text insert end \\\n",\ " \"Num\\n Number of fieldlines to calculate. (May not be used exactly.)\"\n",\ " $text insert end \\\n",\ " \"Field dependent density\\n There will be more fieldline startpoints where the field is stronger\\n\\n\"\n",\ " $text insert end \\\n",\ " \"Animate periodic\\n (for quasistationary fields) The fieldlines of the different phase angles are animated.\\n ATTENTION: \\\"Fix Phase\\\" has to be turned off\\n\\n\"\n",\ " $text insert end \\\n",\ " \"Vector Function\\n The function fixing the direction of the lines\\n\\n\"\n",\ " $text insert end \\\n",\ " \"Fix Phase\\n (for quasistationary fields) Only calculate and draw fieldlines for one special phase angle.\\n\\n\"\n",\ " $text insert end \\\n",\ " \"Startpoints in Box\\n Set the startpoints inside the box \\[Pmin1,Pmax1\\] x \\[Pmin2,Pmax2\\] x \\[Pmin3,Pmax3\\]\\n\"\n",\ " $text insert end \\\n",\ " \" With the button \\\"Bounding Box\\\" the whole bounding box of the geometry is selected.\\n\\n\" \n",\ " $text insert end \\\n",\ " \"Startpoints on Face\\n All startpoints will be set on one face. This face is selected by double-clicking with the mouse.\\n\\n\"\n",\ " $text insert end \\\n",\ " \"Startpoints from File\\n The startpoint information will be read from the selected file.\\n The entries in the file can be as follows:\\n\"\n",\ " $text insert end \\\n",\ " \" point \\n set a (potential) startpoint\\n\"\n",\ " $text insert end \\\n",\ " \" line \\n set n (potential) startpoints on the line from (x1,y1,z1) to (x2,y2,z2)\\n\"\n",\ " $text insert end \\\n",\ " \" box \\n set n (potential) startpoints inside the box \\[x1,x2\\] x \\[y1,y2\\] x \\[z1,z2\\]\\n\"\n",\ " $text insert end \\\n",\ " \" ATTENTION: These are potential startpoints.\\n The total number of startpoints will be bounded by the \\\"Num\\\"-parameter.\\n \\n \\n \\n\"\n",\ " $text insert end \\\n",\ " \"Settings Menu\\n \\n\" bold\n",\ " $text insert end \\\n",\ " \"rel. Length\\n The maximal length of a fieldline relative to the diameter of the geometry.\\n\\n\"\n",\ " $text insert end \\\n",\ " \"max. Points\\n The maximum number of Runge-Kutta steps.\\n\\n\"\n",\ " $text insert end \\\n",\ " \"rel. Thickness\\n The thickness of the fieldlines relative to the diameter of the geometry.\\n\\n\"\n",\ " $text insert end \\\n",\ " \"rel. Tolerance\\n The tolerance for the step-length control of the Runge-Kutta method.\\n\\n\"\n",\ " $text insert end \\\n",\ " \"RK-Type\\n Which Runge-Kutta scheme to use\\n \\n \\n \\n\"\n",\ " $text insert end \\\n",\ " \"Button \\\"Build Fieldlines\\\"\\n\" bold\n",\ " $text insert end \\\n",\ " \" Build the fieldlines.\"\n",\ " \n",\ "\n",\ " $text configure -state disabled\n",\ "\n",\ " pack .fieldlines_help.ht -expand yes -fill both\n",\ "\n",\ " wm withdraw .fieldlines_help\n",\ " wm geom .fieldlines_help +300+200\n",\ " wm deiconify .fieldlines_help\n",\ " wm title .fieldlines_help \"Fieldlines Help\"\n",\ " focus .fieldlines_help\n",\ " \n",\ " }\n",\ "\n",\ "\n",\ " }\n",\ "\n",\ " button $w.bu.cancel -text \"Done\" -command \"destroy $w\"\n",\ " pack $w.bu.calc $w.bu.help $w.bu.cancel -side left -expand yes\n",\ " \n",\ " \n",\ " wm withdraw $w\n",\ " wm geom $w +200+100\n",\ " wm deiconify $w\n",\ " wm title $w \"Fieldlines\"\n",\ " focus $w\n",\ "\n",\ " }\n",\ "\n",\ " global visoptions.fieldlinesstartface\n",\ "\n",\ " \n",\ " set f [$w.nb subwidget draw]\n",\ " set visoptions.fieldlinesstartface [Ng_BCProp getactive]\n",\ " $f.facesettings.index.ent configure -text ${visoptions.fieldlinesstartface}\n",\ "\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "set visual_dialog_pop1 0\n",\ "set visual_dialog_pop2 0\n",\ "set visual_dialog_pop3 0\n",\ "set visual_dialog_pop4 0\n",\ "set visual_dialog_pop5 0\n",\ "set visual_dialog_pop6 0\n",\ "set visual_dialog_pop7 0\n",\ "\n",\ "proc visual_dialog { } {\n",\ "\n",\ " set w .visoptions_dlg\n",\ "\n",\ " \n",\ " global visual_dialog_pop1\n",\ " global visual_dialog_pop2\n",\ " global visual_dialog_pop3\n",\ " global visual_dialog_pop4\n",\ " global visual_dialog_pop5\n",\ " global visual_dialog_pop6\n",\ " global visual_dialog_pop7\n",\ " set visual_dialog_pop1 1\n",\ " set visual_dialog_pop2 1\n",\ " set visual_dialog_pop3 1\n",\ " set visual_dialog_pop4 1\n",\ " set visual_dialog_pop5 1\n",\ " set visual_dialog_pop6 1\n",\ " set visual_dialog_pop7 1\n",\ " \n",\ " if {[winfo exists .visoptions_dlg] == 1} {\n",\ " wm withdraw $w\n",\ " wm deiconify $w\n",\ " focus $w\n",\ " } {\n",\ "\n",\ " toplevel $w\n",\ "\n",\ " checkbutton $w.imaginary -text \"Imaginary Part\" \\\n",\ " -variable visoptions.imaginary \\\n",\ " -command { Ng_Vis_Set parameters; redraw }\n",\ "\n",\ " \n",\ " frame $w.texframe\n",\ "\n",\ " checkbutton $w.texframe.usetexture -text \"Use Textures (\" \\\n",\ " -variable visoptions.usetexture \\\n",\ " -command { Ng_Vis_Set parameters; redraw }\n",\ " \n",\ " checkbutton $w.texframe.lintexture -text \"Linear )\" \\\n",\ " -variable visoptions.lineartexture \\\n",\ " -command { Ng_Vis_Set parametersrange; redraw }\n",\ "\n",\ " \n",\ "\n",\ "\n",\ " checkbutton $w.invcolor -text \"Inverse Color\" \\\n",\ " -variable visoptions.invcolor \\\n",\ " -command { Ng_Vis_Set parametersrange; redraw }\n",\ " \n",\ " checkbutton $w.redrawperiodic -text \"Animate periodic\" \\\n",\ " -variable visoptions.redrawperiodic \\\n",\ " -command { \n",\ " redrawperiodic\n",\ " Ng_Vis_Set parameters; \n",\ " redraw \n",\ " }\n",\ " \n",\ "\n",\ " checkbutton $w.logscale -text \"Log Scale\" \\\n",\ " -variable visoptions.logscale \\\n",\ " -command { Ng_Vis_Set parameters; redraw }\n",\ " \n",\ " checkbutton $w.lineartexture -text \"Use Linear Texture\" \\\n",\ " -variable visoptions.lineartexture \\\n",\ " -command { Ng_Vis_Set parameters; redraw }\n",\ " \n",\ " scale $w.numcols -orient horizontal -length 100 -from 0 -to 50 \\\n",\ " -resolution 1 \\\n",\ " -variable visoptions.numtexturecols \\\n",\ " -command { popupcheckredraw visual_dialog_pop1 }\n",\ "\n",\ " checkbutton $w.showclipsolution -text \"Draw Clipping Plane Solution\" \\\n",\ " -variable visoptions.showclipsolution \\\n",\ " -command { Ng_Vis_Set parameters; redraw }\n",\ "\n",\ " checkbutton $w.showsurfsolution -text \"Draw Surface Solution\" \\\n",\ " -variable visoptions.showsurfacesolution \\\n",\ " -command { Ng_Vis_Set parameters; redraw }\n",\ "\n",\ "\n",\ "\n",\ " frame $w.grid -relief groove -borderwidth 3\n",\ " scale $w.grid.size -orient horizontal -length 100 -from 1 -to 200 \\\n",\ " -label \"Grid\" \\\n",\ " -resolution 1 \\\n",\ " -variable visoptions.gridsize \\\n",\ " -command { popupcheckredraw visual_dialog_pop2 }\n",\ " \n",\ "\n",\ " scale $w.grid.xoffset -orient horizontal -length 80 -from 0 -to 1 \\\n",\ " -label \"x-Offset\" \\\n",\ " -resolution 0.05 \\\n",\ " -variable visoptions.xoffset \\\n",\ " -command { popupcheckredraw visual_dialog_pop3 }\n",\ "\n",\ " scale $w.grid.yoffset -orient horizontal -length 80 -from 0 -to 1 \\\n",\ " -label \"y-Offset\" \\\n",\ " -resolution 0.05 \\\n",\ " -variable visoptions.yoffset \\\n",\ " -command { popupcheckredraw visual_dialog_pop4 }\n",\ "\n",\ "\n",\ " pack $w.showsurfsolution\n",\ " pack $w.grid -fill x -ipady 3\n",\ " pack $w.grid.size $w.grid.xoffset $w.grid.yoffset -side left -expand yes\n",\ "\n",\ "\n",\ "\n",\ " \n",\ "\n",\ "\n",\ " frame $w.deform -relief groove -borderwidth 3\n",\ " checkbutton $w.deform.cb -text \"Deformation\" \\\n",\ " -variable visoptions.deformation \\\n",\ " -command { Ng_Vis_Set parameters; redraw }\n",\ "\n",\ " tixControl $w.deform.sc1 -label \"Scale: \" -integer false \\\n",\ " -variable visoptions.scaledeform1 \\\n",\ " -command { Ng_Vis_Set parameters; redraw } \\\n",\ " -options {\n",\ " entry.width 6\n",\ " label.width 7\n",\ " label.anchor e\n",\ " } \n",\ "\n",\ " scale $w.deform.sc2 -orient horizontal -length 100 -from 0 -to 1 \\\n",\ " -resolution 0.01 \\\n",\ " -variable visoptions.scaledeform2 \\\n",\ " -command { popupcheckredraw visual_dialog_pop5 }\n",\ "\n",\ " pack $w.deform -fill x -ipady 2\n",\ " pack $w.deform.cb $w.deform.sc1 $w.deform.sc2 -side left -expand yes\n",\ " \n",\ "\n",\ " frame $w.as -relief groove -borderwidth 3\n",\ " checkbutton $w.as.autoscale -text \"Autoscale\" \\\n",\ " -variable visoptions.autoscale \\\n",\ " -command { Ng_Vis_Set parameters; redraw }\n",\ "\n",\ " tixControl $w.as.minval -label \"Min-value: \" -integer false \\\n",\ " -variable visoptions.mminval \\\n",\ " -command { Ng_Vis_Set parametersrange; redraw } \\\n",\ " -options {\n",\ " entry.width 6\n",\ " label.width 12\n",\ " label.anchor e\n",\ " } \n",\ " tixControl $w.as.maxval -label \"Max-value: \" -integer false \\\n",\ " -variable visoptions.mmaxval \\\n",\ " -command { Ng_Vis_Set parametersrange; redraw } \\\n",\ " -options {\n",\ " entry.width 6\n",\ " label.width 12\n",\ " label.anchor e\n",\ " } \n",\ "\n",\ " pack $w.as -fill x -ipady 3\n",\ " pack $w.as.autoscale $w.as.minval $w.as.maxval -side left\n",\ "\n",\ "\n",\ "\n",\ "\n",\ " frame $w.iso -relief groove -borderwidth 3\n",\ " pack $w.iso -fill x -ipady 3\n",\ "\n",\ " frame $w.iso.cb\n",\ " pack $w.iso.cb -side left\n",\ "\n",\ " checkbutton $w.iso.cb.isolines -text \"Iso-lines\" \\\n",\ " -variable visoptions.isolines \\\n",\ " -command { Ng_Vis_Set parameters; redraw }\n",\ " pack $w.iso.cb.isolines -side top\n",\ "\n",\ " checkbutton $w.iso.cb.isosurf -text \"Iso-Surface\" \\\n",\ " -variable visoptions.isosurf \\\n",\ " -command { Ng_Vis_Set parameters; redraw }\n",\ " pack $w.iso.cb.isosurf -side top\n",\ "\n",\ "\n",\ "\n",\ " scale $w.iso.numiso -orient horizontal -length 100 -from 2 -to 50 \\\n",\ " -label \"\" \\\n",\ " -resolution 1 \\\n",\ " -variable visoptions.numiso \\\n",\ " -command { popupcheckredraw visual_dialog_pop6 }\n",\ "\n",\ " pack $w.iso.numiso -side left\n",\ "\n",\ "\n",\ "\n",\ " frame $w.iso.subdiv\n",\ " radiobutton $w.iso.subdiv.zero -text \"0\" -variable visoptions.subdivisions -value 0 \\\n",\ " -command { \n",\ " Ng_Vis_Set parameters; redraw;\n",\ " }\n",\ " radiobutton $w.iso.subdiv.one -text \"1\" -variable visoptions.subdivisions -value 1 \\\n",\ " -command { \n",\ " Ng_Vis_Set parameters; redraw;\n",\ " }\n",\ " radiobutton $w.iso.subdiv.two -text \"2\" -variable visoptions.subdivisions -value 2 \\\n",\ " -command { \n",\ " Ng_Vis_Set parameters; redraw;\n",\ " }\n",\ " radiobutton $w.iso.subdiv.three -text \"3\" -variable visoptions.subdivisions -value 3 \\\n",\ " -command { \n",\ " Ng_Vis_Set parameters; redraw;\n",\ " }\n",\ " radiobutton $w.iso.subdiv.four -text \"4\" -variable visoptions.subdivisions -value 4 \\\n",\ " -command { \n",\ " Ng_Vis_Set parameters; redraw;\n",\ " }\n",\ " radiobutton $w.iso.subdiv.five -text \"5\" -variable visoptions.subdivisions -value 5 \\\n",\ " -command { \n",\ " Ng_Vis_Set parameters; redraw;\n",\ " }\n",\ "\n",\ " label $w.iso.subdiv.text -text \"subdivision\"\n",\ "\n",\ " pack $w.iso.subdiv -side right -ipadx 10\n",\ "\n",\ " pack $w.iso.subdiv.text -side top\n",\ " pack $w.iso.subdiv.zero $w.iso.numiso -side left\n",\ " pack $w.iso.subdiv.one $w.iso.numiso -side left\n",\ " pack $w.iso.subdiv.two $w.iso.numiso -side left\n",\ " pack $w.iso.subdiv.three $w.iso.numiso -side left\n",\ " pack $w.iso.subdiv.four $w.iso.numiso -side left\n",\ " pack $w.iso.subdiv.five $w.iso.numiso -side left\n",\ "\n",\ "\n",\ "\n",\ "\n",\ " checkbutton $w.showcurves -text \"Show Curves\" \\\n",\ " -variable visoptions.drawpointcurves \\\n",\ " -command { Ng_Vis_Set parameters; redraw }\n",\ "\n",\ " pack $w.showcurves\n",\ "\n",\ " frame $w.redraw -relief groove -borderwidth 3\n",\ " checkbutton $w.redraw.auto -text \"Auto-redraw\" \\\n",\ " -variable visoptions.autoredraw \n",\ "\n",\ " tixControl $w.redraw.val -label \" after (sec) \" -integer false \\\n",\ " -variable visoptions.autoredrawtime \\\n",\ " -options {\n",\ " entry.width 6\n",\ " label.width 0\n",\ " label.anchor w\n",\ " } \n",\ "\n",\ " pack $w.redraw -fill x -ipady 3\n",\ " pack $w.redraw.auto $w.redraw.val -side left\n",\ "\n",\ "\n",\ "\n",\ " tixControl $w.redraw.simtime -label \" Simulation Time (1e-6 s)\" -integer false \\\n",\ " -variable visoptions.simulationtime \\\n",\ " -command { \n",\ " Ng_Vis_Set time ${visoptions.simulationtime}; \n",\ " catch {NGS_Set time ${visoptions.simulationtime};}\n",\ " redraw } \\\n",\ " -options {\n",\ " entry.width 6\n",\ " label.width 0\n",\ " label.anchor w\n",\ " } \n",\ " pack $w.redraw.simtime -side left\n",\ " \n",\ "\n",\ "\n",\ "\n",\ " tixOptionMenu $w.clipsol -label \"Clipping Plane Sol: \" \\\n",\ " -options {\n",\ " label.width 18\n",\ " label.anchor e\n",\ " menubutton.width 12\n",\ " }\n",\ "\n",\ " set none 1\n",\ " $w.clipsol add command none -label None\n",\ " $w.clipsol add command scal -label \"Scalar Function\"\n",\ " $w.clipsol add command vec -label \"Vector Function\"\n",\ "\n",\ " $w.clipsol configure -variable visoptions.clipsolution\n",\ " $w.clipsol configure -command { Ng_Vis_Set parameters; redraw }\n",\ "\n",\ " pack $w.clipsol\n",\ "\n",\ "\n",\ "\n",\ "\n",\ " tixOptionMenu $w.scalfun -label \"Scalar Function: \" \\\n",\ " -options {\n",\ " label.width 18\n",\ " label.anchor e\n",\ " menubutton.width 12\n",\ " }\n",\ "\n",\ " tixOptionMenu $w.vecfun -label \"Vector Function: \" \\\n",\ " -options {\n",\ " label.width 18\n",\ " label.anchor e\n",\ " menubutton.width 12\n",\ " }\n",\ "\n",\ "\n",\ " $w.scalfun add command none -label None\n",\ " for { set i 1 } { $i <= [Ng_Vis_Field getnfieldnames] } { incr i } {\n",\ " set fname [Ng_Vis_Field getfieldname $i]\n",\ " set fcomp [Ng_Vis_Field getfieldcomponents $i]\n",\ " if { $fcomp == 1 } {\n",\ " $w.scalfun add command $fname.1 -label $fname\n",\ " } {\n",\ " for { set j 1 } { $j <= $fcomp } { incr j } {\n",\ " $w.scalfun add command $fname.$j -label \"$fname ($j)\"\n",\ " }\n",\ " $w.scalfun add command $fname.0 -label \"func ($fname)\"\n",\ " }\n",\ " }\n",\ "\n",\ " $w.vecfun add command none -label None \n",\ " for { set i 1 } { $i <= [Ng_Vis_Field getnfieldnames] } { incr i } {\n",\ " set fname [Ng_Vis_Field getfieldname $i]\n",\ " set fcomp [Ng_Vis_Field getfieldcomponents $i]\n",\ " set iscomplex [Ng_Vis_Field iscomplex $i]\n",\ " set sdim [Ng_Vis_Field getdimension]\n",\ " if { $iscomplex == 1 } { set fcomp [expr $fcomp / 2] }\n",\ " if { ($fcomp == $sdim) || ($fcomp == 3) } {\n",\ " $w.vecfun add command $fname -label $fname\n",\ " } \n",\ " }\n",\ "\n",\ "\n",\ " $w.scalfun configure -variable visoptions.scalfunction \n",\ " $w.scalfun configure -command { Ng_Vis_Set parameters; redraw }\n",\ " $w.vecfun configure -variable visoptions.vecfunction\n",\ " $w.vecfun configure -command { Ng_Vis_Set parameters; redraw }\n",\ "\n",\ "\n",\ "\n",\ "\n",\ " tixOptionMenu $w.evaluate -label \"Evaluate: \" \\\n",\ " -options {\n",\ " label.width 18\n",\ " label.anchor e\n",\ " menubutton.width 12\n",\ " } \n",\ " $w.evaluate add command abs -label \"|.|\"\n",\ " $w.evaluate add command abstens -label \"|tensor|\"\n",\ " $w.evaluate add command mises -label \"Mises\"\n",\ " $w.evaluate add command main -label \"Main\"\n",\ " $w.evaluate configure -variable visoptions.evaluate\n",\ " $w.evaluate configure -command { \n",\ " Ng_Vis_Set parameters; \n",\ " redraw \n",\ " }\n",\ "\n",\ " pack $w.scalfun $w.vecfun $w.evaluate\n",\ "\n",\ " tixControl $w.multidimcomp -label \"multidim-component: \" -integer true \\\n",\ " -variable visoptions.multidimcomponent -min 0 \\\n",\ " -command { Ng_Vis_Set parameters; redraw } \\\n",\ " -options {\n",\ " entry.width 6\n",\ " label.width 18\n",\ " label.anchor e\n",\ " } \n",\ "\n",\ "\n",\ " pack $w.multidimcomp\n",\ "\n",\ " pack $w.imaginary $w.logscale $w.texframe $w.invcolor $w.redrawperiodic\n",\ " pack $w.texframe.usetexture $w.texframe.lintexture -side left -expand yes\n",\ " \n",\ "\n",\ " frame $w.bu\n",\ " pack $w.bu -pady 5\n",\ "\n",\ " button $w.bu.showsol -text \"Show Solution\" -command { \n",\ " set selectvisual solution\n",\ " Ng_SetVisParameters\n",\ " redraw\n",\ " }\n",\ " button $w.bu.clipping -text \"Clipping\" -command { \n",\ " clippingdialog; \n",\ " }\n",\ " button $w.bu.fieldlines -text \"Fieldlines\" -command { \n",\ " fieldlinesdialog; \n",\ " }\n",\ "\n",\ " button $w.bu.lineplot -text \"2D Lineplot\" -command {\n",\ " lineplotdialog;\n",\ " }\n",\ "\n",\ " button $w.bu.done -text \"Close\" -command { \n",\ " destroy .visoptions_dlg\n",\ " }\n",\ "\n",\ " pack $w.bu.showsol $w.bu.clipping $w.bu.fieldlines $w.bu.lineplot $w.bu.done -side left -expand yes\n",\ "\n",\ " wm withdraw $w\n",\ " wm geom $w +100+100\n",\ " wm deiconify $w\n",\ " wm title $w \"Visualization\"\n",\ "\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "proc reset_visual_dialog { } {\n",\ " \n",\ " set w .visoptions_dlg\n",\ " \n",\ " if {[winfo exists .visoptions_dlg] == 1} {\n",\ " \n",\ " \n",\ " destroy $w.scalfun $w.vecfun $w.evaluate $w.multidimcomp\n",\ " destroy $w.imaginary $w.logscale $w.texframe.usetexture $w.texframe.lintexture\n",\ " destroy $w.texframe\n",\ " destroy $w.invcolor $w.redrawperiodic\n",\ " destroy $w.bu -pady 5\n",\ " destroy $w.bu.showsol $w.bu.clipping $w.bu.fieldlines $w.bu.lineplot $w.bu.done -side left -expand yes\n",\ " \n",\ " \n",\ " checkbutton $w.imaginary -text \"Imaginary Part\" \\\n",\ " -variable visoptions.imaginary \\\n",\ " -command { Ng_Vis_Set parameters; redraw }\n",\ "\n",\ " frame $w.texframe\n",\ "\n",\ " checkbutton $w.texframe.usetexture -text \"Use Textures (\" \\\n",\ " -variable visoptions.usetexture \\\n",\ " -command { Ng_Vis_Set parameters; redraw }\n",\ "\n",\ " checkbutton $w.texframe.lintexture -text \"Linear )\" \\\n",\ " -variable visoptions.lineartexture \\\n",\ " -command { Ng_Vis_Set parameters; redraw }\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ " \n",\ " \n",\ " checkbutton $w.invcolor -text \"Inverse Color\" \\\n",\ " -variable visoptions.invcolor \\\n",\ " -command { Ng_Vis_Set parameters; redraw }\n",\ " \n",\ " checkbutton $w.redrawperiodic -text \"Animate periodic\" \\\n",\ " -variable visoptions.redrawperiodic \\\n",\ " -command { \n",\ " redrawperiodic\n",\ " Ng_Vis_Set parameters; \n",\ " redraw \n",\ " }\n",\ " \n",\ "\n",\ " checkbutton $w.logscale -text \"Log Scale\" \\\n",\ " -variable visoptions.logscale \\\n",\ " -command { Ng_Vis_Set parameters; redraw }\n",\ "\n",\ "\n",\ " tixOptionMenu $w.scalfun -label \"Scalar Function: \" \\\n",\ " -options {\n",\ " label.width 18\n",\ " label.anchor e\n",\ " menubutton.width 12\n",\ " }\n",\ "\n",\ " tixOptionMenu $w.vecfun -label \"Vector Function: \" \\\n",\ " -options {\n",\ " label.width 18\n",\ " label.anchor e\n",\ " menubutton.width 12\n",\ " }\n",\ "\n",\ "\n",\ "\n",\ " $w.scalfun add command none -label None\n",\ " for { set i 1 } { $i <= [Ng_Vis_Field getnfieldnames] } { incr i } {\n",\ " set fname [Ng_Vis_Field getfieldname $i]\n",\ " set fcomp [Ng_Vis_Field getfieldcomponents $i]\n",\ " if { $fcomp == 1 } {\n",\ " $w.scalfun add command $fname.1 -label $fname\n",\ " } {\n",\ " for { set j 1 } { $j <= $fcomp } { incr j } {\n",\ " $w.scalfun add command $fname.$j -label \"$fname ($j)\"\n",\ " }\n",\ " $w.scalfun add command $fname.0 -label \"func ($fname)\"\n",\ " }\n",\ " }\n",\ "\n",\ " $w.vecfun add command none -label None \n",\ " for { set i 1 } { $i <= [Ng_Vis_Field getnfieldnames] } { incr i } {\n",\ " set fname [Ng_Vis_Field getfieldname $i]\n",\ " set fcomp [Ng_Vis_Field getfieldcomponents $i]\n",\ " set iscomplex [Ng_Vis_Field iscomplex $i]\n",\ " set sdim [Ng_Vis_Field getdimension]\n",\ " if { $iscomplex == 1 } { set fcomp [expr $fcomp / 2] }\n",\ " if { ($fcomp == $sdim) || ($fcomp == 3) } {\n",\ " $w.vecfun add command $fname -label $fname\n",\ " } \n",\ " }\n",\ "\n",\ "\n",\ "\n",\ " $w.scalfun configure -variable visoptions.scalfunction \n",\ " $w.scalfun configure -command { Ng_Vis_Set parameters; redraw }\n",\ " $w.vecfun configure -variable visoptions.vecfunction\n",\ " $w.vecfun configure -command { Ng_Vis_Set parameters; redraw }\n",\ "\n",\ "\n",\ "\n",\ "\n",\ " tixOptionMenu $w.evaluate -label \"Evaluate: \" \\\n",\ " -options {\n",\ " label.width 18\n",\ " label.anchor e\n",\ " menubutton.width 12\n",\ " } \n",\ " $w.evaluate add command abs -label \"|.|\"\n",\ " $w.evaluate add command abstens -label \"|tensor|\"\n",\ " $w.evaluate add command mises -label \"Mises\"\n",\ " $w.evaluate add command main -label \"Main\"\n",\ " $w.evaluate configure -variable visoptions.evaluate\n",\ " $w.evaluate configure -command { \n",\ " Ng_Vis_Set parameters; \n",\ " redraw \n",\ " }\n",\ "\n",\ " pack $w.scalfun $w.vecfun $w.evaluate\n",\ "\n",\ " tixControl $w.multidimcomp -label \"multidim-component: \" -integer true \\\n",\ " -variable visoptions.multidimcomponent -min 0 \\\n",\ " -command { Ng_Vis_Set parameters; redraw } \\\n",\ " -options {\n",\ " entry.width 6\n",\ " label.width 18\n",\ " label.anchor e\n",\ " } \n",\ "\n",\ "\n",\ " pack $w.multidimcomp\n",\ "\n",\ " pack $w.imaginary $w.logscale $w.texframe $w.invcolor $w.redrawperiodic\n",\ " pack $w.texframe.usetexture $w.texframe.lintexture -side left -expand yes\n",\ "\n",\ "\n",\ " frame $w.bu\n",\ " pack $w.bu -pady 5\n",\ "\n",\ " button $w.bu.showsol -text \"Show Solution\" -command { \n",\ " set selectvisual solution\n",\ " Ng_SetVisParameters\n",\ " redraw\n",\ " }\n",\ " button $w.bu.clipping -text \"Clipping\" -command { \n",\ " clippingdialog; \n",\ " }\n",\ " button $w.bu.fieldlines -text \"Fieldlines\" -command { \n",\ " fieldlinesdialog; \n",\ " }\n",\ "\n",\ " button $w.bu.lineplot -text \"2D Lineplot\" -command {\n",\ " lineplotdialog;\n",\ " }\n",\ "\n",\ " button $w.bu.done -text \"Close\" -command { \n",\ " destroy .visoptions_dlg\n",\ " }\n",\ "\n",\ " pack $w.bu.showsol $w.bu.clipping $w.bu.fieldlines $w.bu.lineplot $w.bu.done -side left -expand yes\n",\ "\n",\ " wm withdraw $w\n",\ " wm deiconify $w\n",\ "\n",\ "\n",\ " }\n",\ "\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "set sockets.serverport 0\n",\ "set sockets.serverhost \"localhost\"\n",\ "set sockets.serverlistbox 0\n",\ "set sockets.queuelistbox 0\n",\ "set sockets.currentjoblistbox 0\n",\ "set sockets.answerlistbox 0\n",\ "set sockets.myidlabel -1\n",\ "\n",\ "\n",\ "proc updateserverlist { } {\n",\ " global sockets.serverlistbox\n",\ " \n",\ " set retval [Ng_Socket getserverlist]\n",\ "\n",\ " ${sockets.serverlistbox} delete 0 end\n",\ "\n",\ " for {set i 0} {$i < [llength $retval]} {incr i 3} {\n",\ " ${sockets.serverlistbox} insert end \\\n",\ " [format \"%-16s %6i %6i\" [lindex $retval $i] [lindex $retval [expr $i+1]] [lindex $retval [expr $i+2]]]\n",\ " }\n",\ "}\n",\ "\n",\ "proc clientsocketdialog { } {\n",\ " set w .clientsock_dlg\n",\ " \n",\ " if {[winfo exists .clientsock_dlg] == 1} {\n",\ " wm withdraw $w\n",\ " wm deiconify $w\n",\ " focus $w \n",\ " } {\n",\ " toplevel $w\n",\ "\n",\ " global sockets.serverhost\n",\ " global sockets.serverport\n",\ "\n",\ " frame $w.general\n",\ " frame $w.host\n",\ " label $w.host.lab -text \"Serverhost: \"\n",\ " entry $w.host.name -width 30 -relief sunken -textvariable sockets.serverhost\n",\ "\n",\ " pack $w.host.lab $w.host.name -side left\n",\ " pack $w.host\n",\ "\n",\ " frame $w.ports\n",\ " label $w.ports.lab1 -text \"Serverport: \"\n",\ " entry $w.ports.statport -width 6 -relief sunken -textvariable sockets.serverport\n",\ " \n",\ " pack $w.ports.lab1 $w.ports.statport -side left\n",\ " pack $w.ports\n",\ "\n",\ " frame $w.listboxes\n",\ "\n",\ " frame $w.listboxes.choosesocketframe\n",\ "\n",\ " tixScrolledListBox $w.listboxes.choosesocketframe.choosesocket -scrollbar auto\n",\ "\n",\ " global sockets.serverlistbox\n",\ "\n",\ " set sockets.serverlistbox [$w.listboxes.choosesocketframe.choosesocket subwidget listbox]\n",\ "\n",\ " ${sockets.serverlistbox} configure -width 35\n",\ " ${sockets.serverlistbox} configure -selectmode browse\n",\ " ${sockets.serverlistbox} configure -exportselection false\n",\ "\n",\ " button $w.addserver -text \"Add ServerSocket\" -command {\n",\ " Ng_Socket addserver ${sockets.serverport} ${sockets.serverhost}\n",\ " updateserverlist\n",\ " }\n",\ " \n",\ " pack $w.addserver\n",\ "\n",\ " label $w.linefeed -text \"\\n\"\n",\ " pack $w.linefeed\n",\ " \n",\ " frame $w.clientidframe\n",\ " label $w.clientidframe.lab -text \"Client ID: \";\n",\ " global sockets.myidlabel\n",\ " entry $w.clientidframe.val -width 5 -relief sunken -textvariable sockets.myidlabel\n",\ " button $w.clientidframe.but -text \"Set\" -command {\n",\ " set opsel [${sockets.serverlistbox} curselection]\n",\ " if {[llength $opsel] > 0} {\n",\ " set opserver [lindex $opsel 0]\n",\ " Ng_Socket setid $opserver ${sockets.myidlabel}\n",\ " updateserverlist\n",\ " }\n",\ " }\n",\ "\n",\ " pack $w.clientidframe.lab $w.clientidframe.val $w.clientidframe.but -side left\n",\ " pack $w.clientidframe\n",\ "\n",\ "\n",\ "\n",\ "\n",\ " label $w.listboxes.choosesocketframe.chooselab -text [format \"\\n\\n%-16s %6s %6s \" Host Socket MyID ]\n",\ " pack $w.listboxes.choosesocketframe.chooselab\n",\ " pack $w.listboxes.choosesocketframe.choosesocket\n",\ "\n",\ " frame $w.listboxes.choosesocketframe.serverbuttons\n",\ "\n",\ " button $w.listboxes.choosesocketframe.serverbuttons.save -text \"Save\" -command {\n",\ " Ng_Socket saveserverlist\n",\ " }\n",\ "\n",\ " global sockets.serverlist\n",\ " Ng_Socket loadserverlist\n",\ " updateserverlist\n",\ "\n",\ " button $w.listboxes.choosesocketframe.serverbuttons.delete -text \"Delete\" -command {\n",\ " set opsel [${sockets.serverlistbox} curselection]\n",\ " if {[llength $opsel] > 0} {\n",\ " Ng_Socket deletesocket [lindex $opsel 0]\n",\ " updateserverlist\n",\ " } \n",\ " }\n",\ " \n",\ " pack $w.listboxes.choosesocketframe.serverbuttons.save $w.listboxes.choosesocketframe.serverbuttons.delete -side left\n",\ " pack $w.listboxes.choosesocketframe.serverbuttons\n",\ "\n",\ " frame $w.listboxes.statusframe\n",\ "\n",\ " label $w.listboxes.statusframe.statuslabel1 -text \"\\n\\njobqueue\"\n",\ "\n",\ " tixScrolledListBox $w.listboxes.statusframe.queuestatus -scrollbar auto\n",\ "\n",\ " label $w.listboxes.statusframe.statuslabel2 -text \"\\ncurrent job\"\n",\ "\n",\ " tixScrolledListBox $w.listboxes.statusframe.currentjobstatus -scrollbar auto\n",\ "\n",\ " label $w.listboxes.statusframe.statuslabel3 -text \"\\nanswers\"\n",\ "\n",\ " tixScrolledListBox $w.listboxes.statusframe.answers -scrollbar auto\n",\ "\n",\ " global sockets.queuelistbox\n",\ " global sockets.currentjoblistbox\n",\ " global sockets.answerlistbox\n",\ "\n",\ " set sockets.queuelistbox [$w.listboxes.statusframe.queuestatus subwidget listbox]\n",\ " set sockets.currentjoblistbox [$w.listboxes.statusframe.currentjobstatus subwidget listbox]\n",\ " set sockets.answerlistbox [$w.listboxes.statusframe.answers subwidget listbox]\n",\ "\n",\ " ${sockets.queuelistbox} configure -width 50\n",\ " ${sockets.queuelistbox} configure -height 5\n",\ " ${sockets.queuelistbox} configure -selectmode browse\n",\ " ${sockets.queuelistbox} configure -exportselection false\n",\ " \n",\ " ${sockets.currentjoblistbox} configure -width 50\n",\ " ${sockets.currentjoblistbox} configure -height 1\n",\ " ${sockets.currentjoblistbox} configure -selectmode browse\n",\ " ${sockets.currentjoblistbox} configure -exportselection false\n",\ "\n",\ " ${sockets.answerlistbox} configure -width 50\n",\ " ${sockets.answerlistbox} configure -height 5\n",\ " ${sockets.answerlistbox} configure -selectmode browse\n",\ " ${sockets.answerlistbox} configure -exportselection false\n",\ "\n",\ " button $w.listboxes.statusframe.updatebutton -text \"Update\" -command {\n",\ " set opsel [${sockets.serverlistbox} curselection]\n",\ " if {[llength $opsel] > 0} {\n",\ " set opserver [lindex $opsel 0]\n",\ " set retval [Ng_Socket sendqueuestatus $opserver]\n",\ "\n",\ " ${sockets.queuelistbox} delete 0 end\n",\ " \n",\ " if {[lindex $retval 0] > 0} {\n",\ " ${sockets.queuelistbox} insert end [format \"Blocked for user %i\" [lindex $retval 0]]\n",\ " } {\n",\ " ${sockets.queuelistbox} insert end \"Not blocked\"\n",\ " }\n",\ " \n",\ " for {set i 2} {$i < [expr 2*[lindex $retval 1]+2]} {incr i 2} {\n",\ " ${sockets.queuelistbox} insert end [format \"client %i, command %s\" [lindex $retval $i] [lindex $retval [expr $i+1]]]\n",\ " }\n",\ " \n",\ " ${sockets.answerlistbox} delete 0 end\n",\ " \n",\ " for {set i [expr 2*[lindex $retval 1]+3]} {$i < [llength $retval]} {incr i 2} {\n",\ " ${sockets.answerlistbox} insert end [format \"client %i, command %s\" [lindex $retval $i] [lindex $retval [expr $i+1]]]\n",\ " }\n",\ "\n",\ " ${sockets.currentjoblistbox} delete 0 end\n",\ " set retval [Ng_Socket sendjobstatus $opserver]\n",\ " if {[lindex $retval 0] != 0} {\n",\ " ${sockets.currentjoblistbox} insert end [format \"client %i, command %s: %s\" [lindex $retval 0] [lindex $retval 1] [lrange $retval 2 end]]\n",\ " }\n",\ " \n",\ " }\n",\ " }\n",\ "\n",\ " pack $w.listboxes.statusframe.statuslabel1 $w.listboxes.statusframe.queuestatus \\\n",\ " $w.listboxes.statusframe.statuslabel2 $w.listboxes.statusframe.currentjobstatus \\\n",\ " $w.listboxes.statusframe.statuslabel3 $w.listboxes.statusframe.answers \\\n",\ " $w.listboxes.statusframe.updatebutton\n",\ "\n",\ " pack $w.listboxes.choosesocketframe $w.listboxes.statusframe -side left\n",\ " \n",\ " pack $w.listboxes\n",\ "\n",\ " label $w.lab1 -text \"\\n\"\n",\ " pack $w.lab1\n",\ "\n",\ "\n",\ " frame $w.buttons1\n",\ " frame $w.buttons2\n",\ " \n",\ " button $w.buttons1.getid -text \"Get ID\" -command {\n",\ " set opsel [${sockets.serverlistbox} curselection]\n",\ " if {[llength $opsel] > 0} {\n",\ " set opserver [lindex $opsel 0]\n",\ " set retval [Ng_Socket getid $opserver]\n",\ " updateserverlist\n",\ " set sockets.myidlabel $retval\n",\ " }\n",\ " }\n",\ "\n",\ " button $w.buttons1.killjob -text \"Kill Cur. Job\" -command {\n",\ " set opsel [${sockets.serverlistbox} curselection]\n",\ " if {[llength $opsel] > 0} {\n",\ " set opserver [lindex $opsel 0]\n",\ " Ng_Socket killcurrentjob $opserver\n",\ " }\n",\ " }\n",\ "\n",\ " button $w.buttons2.sendmesh -text \"Send Mesh\" -command {\n",\ " set opsel [${sockets.serverlistbox} curselection]\n",\ " if {[llength $opsel] > 0} {\n",\ " set opserver [lindex $opsel 0]\n",\ " set retval [Ng_Socket sendmesh $opserver]\n",\ " set sockets.meshsent 1\n",\ " }\n",\ " }\n",\ "\n",\ " button $w.buttons2.sendpde -text \"Send PDE\" -command {\n",\ " set opsel [${sockets.serverlistbox} curselection]\n",\ " if {[llength $opsel] > 0} {\n",\ " set opserver [lindex $opsel 0]\n",\ " set retval [NGS_Socket sendpdefile $opserver]\n",\ " }\n",\ " }\n",\ "\n",\ " button $w.buttons2.solvepde -text \"Solve PDE\" -command {\n",\ " set opsel [${sockets.serverlistbox} curselection]\n",\ " if {[llength $opsel] > 0} {\n",\ " set opserver [lindex $opsel 0]\n",\ " set retval [NGS_Socket solvepde $opserver]\n",\ " }\n",\ " }\n",\ "\n",\ " button $w.buttons2.writesol -text \"Write Solution\" -command {\n",\ " set opsel [${sockets.serverlistbox} curselection]\n",\ " if {[llength $opsel] > 0} {\n",\ " set opserver [lindex $opsel 0]\n",\ " set retval [NGS_Socket writesolution $opserver]\n",\ " }\n",\ " }\n",\ "\n",\ " button $w.buttons2.sendsol -text \"Receive Solution\" -command {\n",\ " set opsel [${sockets.serverlistbox} curselection]\n",\ " if {[llength $opsel] > 0} {\n",\ " set opserver [lindex $opsel 0]\n",\ " set retval [NGS_Socket sendsolution $opserver]\n",\ " }\n",\ " }\n",\ "\n",\ " button $w.buttons1.blockserver -text \"Block Server\" -command {\n",\ " set opsel [${sockets.serverlistbox} curselection]\n",\ " if {[llength $opsel] > 0} {\n",\ " set opserver [lindex $opsel 0]\n",\ " set retval [Ng_Socket blockserver $opserver]\n",\ " }\n",\ " }\n",\ "\n",\ " button $w.buttons1.unblockserver -text \"UnBlock Server\" -command {\n",\ " set opsel [${sockets.serverlistbox} curselection]\n",\ " if {[llength $opsel] > 0} {\n",\ " set opserver [lindex $opsel 0]\n",\ " set retval [Ng_Socket unblockserver $opserver]\n",\ " }\n",\ " }\n",\ "\n",\ " \n",\ " pack $w.buttons1.getid $w.buttons1.blockserver $w.buttons1.unblockserver $w.buttons1.killjob -side left\n",\ " pack $w.buttons2.sendmesh $w.buttons2.sendpde $w.buttons2.solvepde $w.buttons2.writesol $w.buttons2.sendsol -side left\n",\ "\n",\ " pack $w.buttons1 $w.buttons2\n",\ "\n",\ "\n",\ " wm withdraw $w\n",\ " wm geom $w +200+200\n",\ " wm deiconify $w\n",\ " wm title $w \"Client Socket\"\n",\ " focus .options_dlg\n",\ "\n",\ " }\n",\ " \n",\ "\n",\ "}\n",\ "\n",\ ".ngmenu.special add command -label \"Client Socket\" \\\n",\ " -command { clientsocketdialog }\n",\ "\n",\ "\n",\ "\n",\ "set entities [ ]\n",\ "\n",\ "\n",\ "proc acisdialogbuildtree {} {\n",\ "\n",\ " global entities\n",\ "\n",\ " set w .acis_dlg\n",\ " set hlist [$w.mtre subwidget hlist]\n",\ " \n",\ " set entities [Ng_ACISCommand getentities]\n",\ "\n",\ " set nrentities [expr [llength $entities]]\n",\ "\n",\ " if {$nrentities != 0} {\n",\ "\n",\ " $hlist add Topology -itemtype text -text \"Topology\"\n",\ " \n",\ " set i [expr 0]\n",\ " while {$i < $nrentities} {\n",\ " set entity [lindex $entities [expr $i]]\n",\ " incr i 1\n",\ " set entityname [lindex $entities [expr $i]]\n",\ " $hlist add Topology/$entity -text $entityname -data $entityname\n",\ " incr i 1\n",\ " $w.mtre close Topology/$entity\n",\ " }\n",\ " \n",\ " $w.mtre autosetmode\n",\ " $w.mtre open Topology\n",\ " \n",\ " set i [expr 0]\n",\ " while {$i < $nrentities} {\n",\ " set entity [lindex $entities [expr $i]]\n",\ " $w.mtre close Topology/$entity\n",\ " incr i 2\n",\ " }\n",\ "\n",\ " $w.mtre autosetmode\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "proc rebuildacisdialog {} {\n",\ " if {[winfo exists .acis_dlg] == 1} {\n",\ " [.acis_dlg.mtre subwidget hlist] delete all\n",\ " acisdialogbuildtree \n",\ " }\n",\ "}\n",\ "\n",\ "proc checkacisloaded { } {\n",\ " set isacisgeometryloaded [Ng_ACISCommand isacisgeometryloaded]\n",\ " if {$isacisgeometryloaded == 0} {\n",\ " puts \"no IGES/STEP geometry loaded\"\n",\ " destroy .acis_dlg\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "proc selectentity { entityname } {\n",\ " global entities\n",\ " set nrentities [expr [llength $entities]]\n",\ " set i [expr 0]\n",\ " while {$i < $nrentities} {\n",\ " set entitylength []\n",\ " \n",\ " set entity2 [lindex $entities [expr $i]]\n",\ " incr i 1\n",\ " set entityname2 [lindex $entities [expr $i]]\n",\ " incr i 1\n",\ " set entityname2 [string range $entityname2 0 [expr [string length $entityname]-1]]\n",\ " \n",\ " if {$entityname == $entityname2} {\n",\ " set hlist [.acis_dlg.mtre subwidget hlist]\n",\ " .acis_dlg.mtre open Topology\n",\ " set slashpos [string last \"/\" $entity2]\n",\ " set entity3 [string range $entity2 0 [expr $slashpos-1]]\n",\ " while {$slashpos != -1} {\n",\ " .acis_dlg.mtre open Topology/$entity3\n",\ " \n",\ " set slashpos [string last \"/\" $entity3]\n",\ " set entity3 [string range $entity3 0 [expr $slashpos-1]]\n",\ " }\n",\ " $hlist selection clear\n",\ " $hlist see Topology/$entity2\n",\ " $hlist selection set Topology/$entity2\n",\ " } \n",\ " } \n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "proc acisdialog { } {\n",\ " \n",\ " uplevel 1 {\n",\ " \n",\ " global entities\n",\ " set selectvisual geometry\n",\ " Ng_SetVisParameters\n",\ " redraw\n",\ " \n",\ " set w .acis_dlg\n",\ "\n",\ " if {[winfo exists .acis_dlg] == 1} {\n",\ " wm withdraw $w\n",\ " wm deiconify $w\n",\ " focus $w \n",\ " } { \n",\ " toplevel $w\n",\ " \n",\ " tixTree $w.mtre -options { separator \"/\" }\n",\ " pack $w.mtre -fill both -expand yes\n",\ "\n",\ "\n",\ " acisdialogbuildtree\n",\ "\n",\ " set hlist [$w.mtre subwidget hlist]\n",\ "\n",\ "\n",\ " \n",\ "\n",\ " set solname {\"\"}\n",\ "\n",\ " puts \"acisdialog2\"\n",\ " \n",\ "\n",\ " bind $hlist {\n",\ "\n",\ " set entry [[.acis_dlg.mtre subwidget hlist] info selection]\n",\ " set hentry [string trimleft $entry Topology/]\n",\ "\n",\ " Ng_ACISCommand selectentity $hentry\n",\ " redraw\n",\ " }\n",\ " \n",\ "\n",\ " bind $hlist {\n",\ "\n",\ " puts \"double 1\"\n",\ "\n",\ " set oldsolname {$solname}\n",\ " set solname [[.acis_dlg.mtre subwidget hlist] info selection]\n",\ "\n",\ " puts \"solname = $solname\"\n",\ "\n",\ " if {$solname != \"\" && $oldsolname != $solname } {\n",\ " set seppos [string first \"/\" $solname]\n",\ " set rootname [string range $solname 0 [expr $seppos-1]]\n",\ " \n",\ " set entityname [[.acis_dlg.mtre subwidget hlist] info data $solname]\n",\ " set spacepos [string first \" \" $entityname]\n",\ " set entitytype [string range $entityname 0 [expr $spacepos-1]]\n",\ " set helpstring [string range $entityname [expr $spacepos+1] [expr [string length $entityname]-1]]\n",\ " set spacepos2 [string first \" \" $helpstring]\n",\ " set entitynumber [string range $helpstring 0 [expr $spacepos2-1]]\n",\ " if {$rootname == \"Topology\"} {\n",\ " Ng_ACISCommand highlightentity $entitytype $entitynumber\n",\ " set selectvisual geometry\n",\ " redraw\n",\ " } {\n",\ " set brackpos [string first \" (\" $entityname]\n",\ " if {$brackpos != -1} {\n",\ " set entityname [string range $entityname 0 $brackpos]\n",\ " }\n",\ "\n",\ " selectentity $entityname\n",\ " }\n",\ " }\n",\ " }\n",\ " \n",\ " button $w.cl -text \"Close\" -command {\n",\ " destroy .acis_dlg\n",\ " }\n",\ " \n",\ " puts \"acisdialog3\"\n",\ "\n",\ " button $w.show -text \"Show\" -command {\n",\ " set solname [[.acis_dlg.mtre subwidget hlist] info selection]\n",\ " set entityname [[.acis_dlg.mtre subwidget hlist] info data $solname]\n",\ " set spacepos [string first \" \" $entityname]\n",\ " set entitytype [string range $entityname 0 [expr $spacepos-1]]\n",\ " set helpstring [string range $entityname [expr $spacepos+1] [expr [string length $entityname]-1]]\n",\ " set spacepos2 [string first \" \" $helpstring]\n",\ " set entitynumber [string range $helpstring 0 [expr $spacepos2-1]]\n",\ "\n",\ " Ng_ACISCommand show $entitytype $entitynumber\n",\ " set selectvisual geometry\n",\ " redraw\n",\ " }\n",\ " button $w.hide -text \"Hide\" -command {\n",\ " set solname [[.acis_dlg.mtre subwidget hlist] info selection]\n",\ " set entityname [[.acis_dlg.mtre subwidget hlist] info data $solname]\n",\ " set spacepos [string first \" \" $entityname]\n",\ " set entitytype [string range $entityname 0 [expr $spacepos-1]]\n",\ " set helpstring [string range $entityname [expr $spacepos+1] [expr [string length $entityname]-1]]\n",\ " set spacepos2 [string first \" \" $helpstring]\n",\ " set entitynumber [string range $helpstring 0 [expr $spacepos2-1]]\n",\ "\n",\ " Ng_ACISCommand hide $entitytype $entitynumber\n",\ " set selectvisual geometry\n",\ " redraw\n",\ " }\n",\ "\n",\ " button $w.swaporientation -text \"Swap orientation\" -command {\n",\ " set solname [[.acis_dlg.mtre subwidget hlist] info selection]\n",\ " set entityname [[.acis_dlg.mtre subwidget hlist] info data $solname]\n",\ " set spacepos [string first \" \" $entityname]\n",\ " set entitytype [string range $entityname 0 [expr $spacepos-1]]\n",\ " set helpstring [string range $entityname [expr $spacepos+1] [expr [string length $entityname]-1]]\n",\ " set spacepos2 [string first \" \" $helpstring]\n",\ " set entitynumber [string range $helpstring 0 [expr $spacepos2-1]]\n",\ "\n",\ " Ng_ACISCommand swaporientation $entitytype $entitynumber\n",\ " set selectvisual geometry\n",\ " redraw\n",\ "\n",\ " [.acis_dlg.mtre subwidget hlist] delete all\n",\ " acisdialogbuildtree \n",\ " }\n",\ "\n",\ " button $w.marksingular -text \"Mark/Unmark as singular\" -command {\n",\ " set solname [[.acis_dlg.mtre subwidget hlist] info selection]\n",\ " set entityname [[.acis_dlg.mtre subwidget hlist] info data $solname]\n",\ " set spacepos [string first \" \" $entityname]\n",\ " if { $spacepos != 0 } {\n",\ " set entitytype [string range $entityname 0 [expr $spacepos-1]]\n",\ " set helpstring [string range $entityname [expr $spacepos+1] [expr [string length $entityname]-1]]\n",\ " set spacepos2 [string first \" \" $helpstring]\n",\ " if { $spacepos2 != 0 } {\n",\ " set entitynumber [string range $helpstring 0 [expr $spacepos2-1]]\n",\ " \n",\ " global ismarkedsingular\n",\ " Ng_ACISCommand marksingular $entitytype $entitynumber\n",\ " \n",\ " set hlist [$w.mtre subwidget hlist]\n",\ " \n",\ " set style1 [tixDisplayStyle imagetext -foreground black -background white -selectforeground white -selectbackground blue]\n",\ " set style2 [tixDisplayStyle imagetext -foreground red -background white -selectforeground red -selectbackground blue]\n",\ " \n",\ " if { $ismarkedsingular == 0 } {\n",\ " $hlist entryconfigure $solname -style $style1\n",\ " } {\n",\ " $hlist entryconfigure $solname -style $style2\n",\ " }\n",\ "\n",\ " }\n",\ " }\n",\ " \n",\ " \n",\ " }\n",\ "\n",\ "\n",\ " checkbutton $w.zoomtohighlightedentity -text \"Zoom to highlighted entity\" \\\n",\ " -variable acisoptions.zoomtohighlightedentity \\\n",\ " -command {\n",\ " Ng_SetACISVisParameters\n",\ " if { ${acisoptions.zoomtohighlightedentity} == 1} {\n",\ " set selectvisual geometry\n",\ " Ng_ACISCommand redrawstatus 1\n",\ " redraw\n",\ " } {\n",\ " Ng_ACISCommand redrawstatus 0\n",\ " }\n",\ " }\n",\ "\n",\ "\n",\ "\n",\ " frame $w.healing -relief groove -borderwidth 3\n",\ "\n",\ " button $w.healing.checkentities -text \"Analyze geometry\" -command {\n",\ " set irregent [Ng_ACISCommand findsmallentities]\n",\ "\n",\ " set w .acis_dlg\n",\ " set hlist [$w.mtre subwidget hlist]\n",\ " \n",\ " $hlist add ProblematicEntities -text \"Problematic Entities\"\n",\ " $hlist delete offsprings ProblematicEntities\n",\ "\n",\ " set nritems [expr [llength $irregent]]\n",\ " set i [expr 0]\n",\ " while {$i < $nritems} {\n",\ " set entity [lindex $irregent [expr $i]]\n",\ " incr i 1\n",\ " set entityname [lindex $irregent [expr $i]]\n",\ " $hlist add ProblematicEntities/$entity -text $entityname -data $entityname\n",\ " incr i 1\n",\ " }\n",\ " $w.mtre open ProblematicEntities\n",\ " $w.mtre autosetmode\n",\ " }\n",\ "\n",\ " tixControl $w.healing.tolerance -label \"Healing tolerance: \" -integer false \\\n",\ " -variable acisoptions.tolerance -min 1e-9 -max 1e6 \\\n",\ " -options {\n",\ " entry.width 6\n",\ " label.width 25\n",\ " label.anchor e\n",\ " } \n",\ "\n",\ " checkbutton $w.healing.fixsmalledges -text \"Fix small edges\" \\\n",\ " -variable acisoptions.fixsmalledges\n",\ " \n",\ " checkbutton $w.healing.fixspotstripfaces -text \"Fix spot/strip faces\" \\\n",\ " -variable acisoptions.fixspotstripfaces\n",\ " \n",\ " checkbutton $w.healing.sewfaces -text \"Sew faces\" \\\n",\ " -variable acisoptions.sewfaces\n",\ " \n",\ " checkbutton $w.healing.makesolids -text \"Make solids\" \\\n",\ " -variable acisoptions.makesolids\n",\ " \n",\ " checkbutton $w.healing.splitpartitions -text \"Split partitions\" \\\n",\ " -variable acisoptions.splitpartitions\n",\ " \n",\ " button $w.healing.heal -text \"Heal geometry\" -command { \n",\ " .acis_dlg.healing.tolerance invoke\n",\ " Ng_ACISCommand shapehealing\n",\ " redraw \n",\ " [.acis_dlg.mtre subwidget hlist] delete all\n",\ " acisdialogbuildtree\n",\ " }\n",\ "\n",\ " pack $w.healing.checkentities\n",\ "\n",\ " pack $w.healing.tolerance $w.healing.fixsmalledges \\\n",\ " $w.healing.fixspotstripfaces $w.healing.sewfaces \\\n",\ " $w.healing.makesolids $w.healing.splitpartitions -anchor w\n",\ "\n",\ " pack $w.healing.heal \n",\ "\n",\ "\n",\ "\n",\ "\n",\ " pack $w.show $w.hide\n",\ "\n",\ " pack $w.zoomtohighlightedentity -anchor w\n",\ " pack $w.swaporientation\n",\ " pack $w.marksingular\n",\ " pack $w.healing -fill x\n",\ " pack $w.cl\n",\ " \n",\ " \n",\ " wm withdraw $w\n",\ " wm geom $w +100+100\n",\ " wm deiconify $w\n",\ " wm title $w \"IGES/STEP Topology Explorer/Doctor\"\n",\ " focus .acis_dlg\n",\ " }\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "if { [catch { NGS_GetData } ] == 0 } { \n",\ " \n",\ " set progname \"NGSolve\"\n",\ " wm title . $progname\n",\ " \n",\ " .ngmenu add cascade -label \"Solve\" -menu .ngmenu.solve -underline 1\n",\ " \n",\ " \n",\ " menu .ngmenu.solve\n",\ " .ngmenu.solve add command -label \"Print Equations\" \\\n",\ " -command { NGS_PrintRegistered }\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ " menu .ngmenusolvehelp\n",\ " .ngmenu.solve add cascade -label \"Help\" -menu .ngmenusolvehelp\n",\ " \n",\ " .ngmenusolvehelp add command -label \"Coefficient...\" \\\n",\ " -command { tk_messageBox -title \"Help\" -message [ NGS_Help coefficient ] -type ok }\n",\ " .ngmenusolvehelp add command -label \"Bilinear-form...\" \\\n",\ " -command { tk_messageBox -title \"Help\" -message [ NGS_Help bilinearform ] -type ok }\n",\ " .ngmenusolvehelp add command -label \"Linear-form...\" \\\n",\ " -command { tk_messageBox -title \"Help\" -message [ NGS_Help linearform ] -type ok }\n",\ "\n",\ " .ngmenusolvehelp add cascade -label \"Numprocs...\" -menu .ngmenusolvehelpnp \n",\ " \n",\ " .ngmenusolvehelp add command -label \"Latest News...\" \\\n",\ " -command { tk_messageBox -title \"Latest News\" -message \\\n",\ " { \n",\ " 06042004 online documentation (JS) \n",\ " } -type ok } ;\n",\ " \n",\ "\n",\ "\n",\ " .ngmenu.solve add command -label \"Load PDE...\" -accelerator \"

\"\\\n",\ " -command { \n",\ " set types { {\"Partial Differential Equation\" {.pde} } }\n",\ " set file [tk_getOpenFile -filetypes $types]\n",\ " if {$file != \"\"} {\n",\ " AddRecentNGSFile $file;\n",\ " NGS_LoadPDE $file; \n",\ " set selectvisual mesh;\n",\ " Ng_SetVisParameters \n",\ " }\n",\ " }\n",\ " \n",\ " .ngmenu.solve add cascade -label \"Recent Files\" -menu .ngmenu.solve.recent \n",\ " menu .ngmenu.solve.recent\n",\ "\n",\ " .ngmenu.solve add command -label \"Components...\" \\\n",\ " -command { componentsdialog }\n",\ " \n",\ "\n",\ " .ngmenu.solve add command -label \"Print Report\" \\\n",\ " -command { NGS_PrintPDE }\n",\ "\n",\ " .ngmenu.solve add command -label \"Memory Usage\" \\\n",\ " -command { NGS_PrintMemoryUsage }\n",\ "\n",\ " .ngmenu.solve add command -label \"Print Timing\" \\\n",\ " -command { NGS_PrintTiming }\n",\ "\n",\ "\n",\ "\n",\ " \n",\ "\n",\ "\n",\ "\n",\ " .ngmenu.solve add command -label \"Solve Recent PDE\" -accelerator \"\"\\\n",\ " -command { \n",\ " NGS_LoadPDE [.ngmenu.solve.recent entrycget 1 -label]\n",\ " NGS_SolvePDE\n",\ " set selectvisual solution\n",\ " Ng_SetVisParameters \n",\ "\n",\ "\n",\ " redraw\n",\ " }\n",\ "\n",\ "\n",\ "\n",\ "\n",\ " button .bubar.pde -text \"Recent\" \\\n",\ " -command { .ngmenu.solve invoke \"Solve Recent PDE\"; }\n",\ " pack .bubar.pde -side right\n",\ "\n",\ " button .bubar.solve -text \"Solve\" \\\n",\ " -command { .ngmenu.solve invoke \"Solve PDE\"; }\n",\ " pack .bubar.solve -side right\n",\ "\n",\ " button .bubar.visualize -text \"Visual\" \\\n",\ " -command { visual_dialog }\n",\ " pack .bubar.visualize -side right\n",\ "\n",\ " .ngmenu.solve add command -label \"Solve PDE\" -accelerator \"

\"\\\n",\ " -command {\n",\ " \n",\ " \n",\ " \n",\ " NGS_SolvePDE\n",\ " set selectvisual solution\n",\ " Ng_SetVisParameters \n",\ "\n",\ " Ng_Vis_Set parameters; \n",\ "\n",\ " \n",\ " redraw\n",\ " }\n",\ "\n",\ " .ngmenu.solve add cascade -label \"Solve PDE x\" -menu .ngmenu.solve.solvex\n",\ " menu .ngmenu.solve.solvex\n",\ "\n",\ " proc SolveX { num } {\n",\ " for { set i 1 } { $i <= $num } { incr i } {\n",\ " uplevel 1 \"NGS_SolvePDE $i\"\n",\ " }\n",\ " }\n",\ "\n",\ " .ngmenu.solve.solvex add command -label \"1 Level\" -command { SolveX 1 }\n",\ " .ngmenu.solve.solvex add command -label \"2 Level\" -command { SolveX 2 }\n",\ " .ngmenu.solve.solvex add command -label \"3 Level\" -command { SolveX 3 }\n",\ " .ngmenu.solve.solvex add command -label \"4 Level\" -command { SolveX 4 }\n",\ " .ngmenu.solve.solvex add command -label \"5 Level\" -command { SolveX 5 }\n",\ " .ngmenu.solve.solvex add command -label \"6 Level\" -command { SolveX 6 }\n",\ " .ngmenu.solve.solvex add command -label \"7 Level\" -command { SolveX 7 }\n",\ " .ngmenu.solve.solvex add command -label \"8 Level\" -command { SolveX 8 }\n",\ " .ngmenu.solve.solvex add command -label \"9 Level\" -command { SolveX 9 }\n",\ " .ngmenu.solve.solvex add command -label \"10 Level\" -command { SolveX 10 }\n",\ " .ngmenu.solve.solvex add command -label \"11 Level\" -command { SolveX 11 }\n",\ " .ngmenu.solve.solvex add command -label \"12 Level\" -command { SolveX 12 }\n",\ " .ngmenu.solve.solvex add command -label \"13 Level\" -command { SolveX 13 }\n",\ " .ngmenu.solve.solvex add command -label \"14 Level\" -command { SolveX 14 }\n",\ " .ngmenu.solve.solvex add command -label \"15 Level\" -command { SolveX 15 }\n",\ " .ngmenu.solve.solvex add command -label \"16 Level\" -command { SolveX 16 }\n",\ " .ngmenu.solve.solvex add command -label \"17 Level\" -command { SolveX 17 }\n",\ " .ngmenu.solve.solvex add command -label \"18 Level\" -command { SolveX 18 }\n",\ " .ngmenu.solve.solvex add command -label \"19 Level\" -command { SolveX 19 }\n",\ " .ngmenu.solve.solvex add command -label \"20 Level\" -command { SolveX 20 }\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ " \n",\ "\n",\ " .ngmenu.solve add command -label \"Visualization...\" \\\n",\ " -command { \n",\ " visual_dialog;\n",\ " }\n",\ " \n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ " \n",\ " .ngmenu.solve add command -label \"Save Solution...\" \\\n",\ " -command { \n",\ " set types { {\"Solution File\" {.sol} } }\n",\ " set file [tk_getSaveFile -filetypes $types -defaultextension \".sol\" ]\n",\ " if {$file != \"\"} {\n",\ " NGS_SaveSolution $file \n",\ " }\n",\ " }\n",\ " \n",\ " .ngmenu.solve add command -label \"Load Solution...\" \\\n",\ " -command { \n",\ " set types { {\"Solution File\" {.sol} } }\n",\ " set file [tk_getOpenFile -filetypes $types -defaultextension \".sol\" ]\n",\ " if {$file != \"\"} {\n",\ " NGS_LoadSolution $file \n",\ " set selectvisual solution\n",\ " Ng_SetVisParameters\n",\ " redraw\n",\ " }\n",\ " }\n",\ "\n",\ " \n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ ".ngmenu.help delete \"About...\"\n",\ ".ngmenu.help add command -label \"About...\" \\\n",\ " -command {\n",\ " tk_messageBox -message \\\n",\ " \"This is NETGEN/NGSolve \\n mainly written by \\n Joachim Schöberl \\n\\\n",\ " at RWTH Aachen University, Germany \\n\\\n",\ " and Johannes Kepler University, Linz, Austria \\n\\\n",\ " supported by the Austrian Science Foundation FWF \\n\\\n",\ " thanks to \\n\\\n",\ " F. Bachinger, A. Becirovic, H. Egger, R. Gaisbauer, J. Gerstmayr, U. Langer, A. Sinwel, M. Wabro, S. Zaglmayr\"\n",\ " }\n",\ " \n",\ "\n",\ "\n",\ " proc AddRecentNGSFile { filename } {\n",\ " global progname\n",\ " catch { [.ngmenu.solve.recent delete $filename] }\n",\ " .ngmenu.solve.recent insert 0 command -label $filename \\\n",\ " -command \"AddRecentNGSFile {$filename}; \n",\ " NGS_LoadPDE {$filename};\n",\ " set selectvisual mesh;\n",\ " Ng_SetVisParameters \n",\ " wm title . [concat \\\" $progname - $filename \\\"];\"\n",\ " \n",\ " if { [.ngmenu.solve.recent index last] >= 6 } {\n",\ " .ngmenu.solve.recent delete last }\n",\ " \n",\ " savengsinifile;\n",\ " }\n",\ " \n",\ "\n",\ " proc savengsinifile { } {\n",\ " uplevel 1 {\n",\ " set datei [open ngs.ini w]\n",\ " for { set i [.ngmenu.solve.recent index last] } { $i >= 1 } { incr i -1 } {\n",\ " puts $datei \"recentfile \\\"[.ngmenu.solve.recent entrycget $i -label]\\\"\"\n",\ " }\n",\ " \n",\ " close $datei\n",\ " }\n",\ " }\n",\ " \n",\ " proc loadngsinifile { } {\n",\ " if { [file exists ngs.ini] == 1 } {\n",\ " set datei [open ngs.ini r]\n",\ " while { [gets $datei line] >= 0 } {\n",\ " if {[lindex $line 0] == \"recentfile\"} {\n",\ " AddRecentNGSFile [lindex $line 1]\n",\ " }\n",\ " }\n",\ " close $datei\n",\ " }\n",\ " }\n",\ "\n",\ "\n",\ "loadngsinifile;\n",\ " \n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ " proc componentsdialog { } {\n",\ " \n",\ " set w .components_dlg\n",\ " \n",\ " if {[winfo exists .components_dlg] == 1} {\n",\ " wm withdraw $w\n",\ " wm deiconify $w\n",\ " focus $w \n",\ " } {\n",\ "\n",\ " toplevel $w\n",\ "\n",\ "\n",\ " tixTree $w.mtre -options { separator \"\\\\\" }\n",\ " pack $w.mtre -fill both -expand y\n",\ " set hlist [$w.mtre subwidget hlist]\n",\ "\n",\ "\n",\ "\n",\ "\n",\ " $hlist add coeffs -itemtype text -text \"Coefficients\"\n",\ " set coefs [NGS_GetData coefficients]\n",\ " foreach coef $coefs {\n",\ " $hlist add coeffs\\\\$coef -itemtype text -text $coef\n",\ " }\n",\ "\n",\ "\n",\ " $hlist add spaces -itemtype text -text \"Spaces\"\n",\ " set spaces [NGS_GetData spaces]\n",\ " foreach space $spaces {\n",\ " $hlist add spaces\\\\$space -itemtype text -text $space\n",\ " }\n",\ "\n",\ " $hlist add biforms -itemtype text -text \"Bilinear-forms\"\n",\ " set biforms [NGS_GetData bilinearforms]\n",\ " foreach biform $biforms {\n",\ " $hlist add biforms\\\\$biform -itemtype text -text $biform\n",\ " }\n",\ "\n",\ " $hlist add liforms -itemtype text -text \"Linear-forms\"\n",\ " set liforms [NGS_GetData linearforms]\n",\ " foreach liform $liforms {\n",\ " $hlist add liforms\\\\$liform -itemtype text -text $liform\n",\ " }\n",\ "\n",\ " $hlist add gridfuns -itemtype text -text \"Grid-functions\"\n",\ " set gridfuns [NGS_GetData gridfunctions]\n",\ " foreach gridfun $gridfuns {\n",\ " $hlist add gridfuns\\\\$gridfun -itemtype text -text $gridfun\n",\ " }\n",\ "\n",\ " $hlist add preconds -itemtype text -text \"Preconditioners\"\n",\ " set preconds [NGS_GetData preconditioners]\n",\ " foreach precond $preconds {\n",\ " $hlist add preconds\\\\$precond -itemtype text -text $precond\n",\ " }\n",\ "\n",\ " $hlist add numprocs -itemtype text -text \"NumProcs\"\n",\ " set numprocs [NGS_GetData numprocs]\n",\ " foreach numproc $numprocs {\n",\ " $hlist add numprocs\\\\$numproc -itemtype text -text $numproc\n",\ " }\n",\ "\n",\ "\n",\ "\n",\ " \n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ " $w.mtre autosetmode\n",\ " \n",\ "\n",\ " bind $hlist {\n",\ " set solname [[.components_dlg.mtre subwidget hlist] info selection]\n",\ " puts $solname\n",\ " set seppos [string first \\\\ $solname]\n",\ " if { $seppos != -1 } {\n",\ " set field [string range $solname 1 [expr $seppos-1]]\n",\ " set name [string range $solname [expr $seppos+1] [expr [string length $solname]-2]]\n",\ " puts \"field = $field, name = $name\"\n",\ " NGS_PrintPDE $field $name\n",\ " }\n",\ " }\n",\ "\n",\ " button $w.cl -text \"Close\" -command {\n",\ " destroy .components_dlg\n",\ " }\n",\ "\n",\ " pack $w.cl\n",\ " \n",\ " \n",\ " wm withdraw $w\n",\ " wm geom $w +100+100\n",\ " wm deiconify $w\n",\ " wm title $w \"Components\"\n",\ " focus .components_dlg\n",\ " }\n",\ " }\n",\ "\n",\ "bind .

{ .ngmenu.solve invoke \"Load PDE...\" } ; \n",\ "bind . { .ngmenu.solve invoke \"Solve Recent PDE\" } ; \n",\ "bind .

{ .ngmenu.solve invoke \"Solve PDE\" } ; \n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "set zugstange 0\n",\ "\n",\ "\n",\ "catch { source ${ngdir}/trafo/menu.tcl }\n",\ "\n",\ "\n",\ "\n",\ "setgranularity ${meshoptions.fineness}\n",\ "\n",\ "Ng_SetMeshingParameters\n",\ "Ng_SetVisParameters\n",\ "Ng_SetDebugParameters\n",\ "Ng_STLDoctor\n",\ "Ng_GeometryOptions set\n",\ "Ng_SetOCCVisParameters\n",\ "\n",\ "if { $batchmode != \"defined\" } {\n",\ " catch { \n",\ " wm protocol . WM_DELETE_WINDOW { .ngmenu.file invoke \"Quit\" }\n",\ " wm deiconify .\n",\ " }\n",\ "}\n",\ "\n",\ "set trafoapp 0\n",\ "catch { source ${ngdir}/trafoapp/trafoapp.tcl }\n",\ "\n",\ "set geofilename [Ng_GetCommandLineParameter geofile]\n",\ "\n",\ "if { $geofilename != \"undefined\" && \n",\ " [info exists trafo] == 0 && $zugstange == 0} {\n",\ "\n",\ " if { [ catch { Ng_LoadGeometry $geofilename } errstring] == 0 } {\n",\ " if { $batchmode != \"defined\" } {\n",\ " AddRecentFile $geofilename\n",\ " }\n",\ " Ng_ParseGeometry\n",\ " if { $batchmode != \"defined\" } {\n",\ " set selectvisual geometry\n",\ " Ng_SetVisParameters\n",\ " redraw\n",\ " wm title . [concat \"$progname - \" $geofilename]\n",\ " }\n",\ " set dirname [file dirname $geofilename]\n",\ " set basefilename [file tail [file rootname $geofilename]]\n",\ " } {\n",\ " puts \"Problem with input file:\"\n",\ " puts \"$errstring\"\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "set cnt 0\n",\ "foreach { gran } { verycoarse coarse moderate fine veryfine } {\n",\ " set cnt [expr $cnt + 1]\n",\ " if { [Ng_GetCommandLineParameter $gran] == \"defined\" } {\n",\ " set meshoptions.fineness $cnt\n",\ " setgranularity ${meshoptions.fineness}\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "set meshfilename [Ng_GetCommandLineParameter meshfile]\n",\ "if { $meshfilename == \"undefined\" } {\n",\ " set meshfilename out.mesh\n",\ "}\n",\ "\n",\ "set meshfiletype [Ng_GetCommandLineParameter meshfiletype]\n",\ "if { $meshfiletype == \"undefined\" } {\n",\ " set meshfiletype netgen\n",\ "}\n",\ "\n",\ "set inputmeshfilename [Ng_GetCommandLineParameter inputmeshfile]\n",\ "\n",\ "set mergemeshfilename [Ng_GetCommandLineParameter mergefile]\n",\ "\n",\ "set meshsizefilename [Ng_GetCommandLineParameter meshsizefile]\n",\ "\n",\ "if { $meshsizefilename != \"undefined\" } {\n",\ " set options.meshsizefilename $meshsizefilename\n",\ "}\n",\ "\n",\ "set refinementfilename [Ng_GetCommandLineParameter refinementfile]\n",\ "\n",\ "\n",\ "if { $batchmode == \"defined\" && $solvemode != \"defined\"} {\n",\ " set options.parthread 0\n",\ " if { $shellmode == \"undefined\" } {\n",\ " set selectvisual mesh\n",\ " Ng_SetVisParameters\n",\ "\n",\ " set meshsize [Ng_GetCommandLineParameter meshsize]\n",\ " if {$meshsize != \"undefined\"} { set options.meshsize $meshsize }\n",\ " \n",\ " if { $inputmeshfilename == \"undefined\" } {\n",\ " Ng_GenerateMesh ${meshoptions.firststep} ${meshoptions.laststep}\n",\ " } else {\n",\ " Ng_LoadMesh $inputmeshfilename\n",\ " if { $mergemeshfilename != \"undefined\" } {\n",\ " Ng_MergeMesh $mergemeshfilename\n",\ " }\n",\ " }\n",\ " \n",\ " if { $refinementfilename != \"undefined\" } {\n",\ " Ng_Bisect $refinementfilename\n",\ " }\n",\ "\n",\ " if { $meshfiletype == \"netgen\" } {\n",\ " Ng_SaveMesh $meshfilename\n",\ " } else {\n",\ " if { [catch { Ng_ExportMesh $meshfilename $meshfiletype } ] == 1 } {\n",\ " puts \"Unknown file format $meshfiletype\"\n",\ " }\n",\ " }\n",\ " Ng_Exit;\n",\ "\n",\ " exit\n",\ " } else {\n",\ " set code [catch { source ${ngdir}/ngtcltk/ngshell.tcl } errcode]\n",\ " if {$code} {\n",\ " puts \"error: $errcode\"\n",\ " } \n",\ " set code [ catch {Ng_RunShell} errcode]\n",\ " if {$code} {\n",\ " puts \"error: $errcode\"\n",\ " } \n",\ " \n",\ " Ng_Exit;\n",\ " exit\n",\ " }\n",\ " \n",\ "}\n",\ "\n",\ "set stereo [Ng_GetCommandLineParameter stereo]\n",\ "if { $stereo == \"defined\" } {\n",\ " set viewoptions.stereo 1 \n",\ " puts \"use stereo mode\" \n",\ " Ng_SetVisParameters; \n",\ " redraw \n",\ "}\n",\ "\n",\ "\n",\ "set scriptfilename [Ng_GetCommandLineParameter script]\n",\ "if { $scriptfilename != \"undefined\" } {\n",\ " if { [catch { source $scriptfilename } errstring] == 1 } {\n",\ " puts \"Error in input: $errstring\"\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "if { [Ng_GetCommandLineParameter help]==\"defined\" } {\n",\ " if { $zugstange == 1 } {\n",\ " print_zug_commandline_help\n",\ " exit;\n",\ " } {\n",\ " if { $trafoapp == 1 } {\n",\ " print_trafo_commandline_help;\n",\ " } {\n",\ " print_commandline_help; \n",\ " Ng_Exit;\n",\ " exit\n",\ " }\n",\ " }\n",\ "}\n",\ "\n",\ "if { [file exists startup.tcl] } {\n",\ " source startup.tcl }\n",\ "\n",\ "if { [Ng_GetCommandLineParameter recent]==\"defined\" } {\n",\ " if { [catch { .ngmenu.solve invoke \"Solve Recent PDE\"; } errstring] == 1 } {\n",\ " puts \"TCL-ERROR handler:\\n $errstring\";\n",\ " exit;\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "set pdefilename [Ng_GetCommandLineParameter pdefile]\n",\ "if { $pdefilename != \"undefined\" } {\n",\ " NGS_LoadPDE $pdefilename; \n",\ "\n",\ " set solve [Ng_GetCommandLineParameter solve]\n",\ " if { $zugstange == 1 } {\n",\ " set options.parthread 0\n",\ " NGS_SolvePDE;\n",\ " } {\n",\ " if { $solve == \"defined\" } {\n",\ " set options.parthread 0\n",\ " NGS_SolvePDE\n",\ " exit;\n",\ " } {\n",\ " if { $solve != \"undefined\" } {\n",\ " set options.parthread 0\n",\ " for { set l 1 } { $l <= $solve } { incr l } { NGS_SolvePDE $l }\n",\ " exit;\n",\ " }\n",\ " }\n",\ " }\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "catch { source ${ngdir}/trafo/trafo.tcl }\n",\ "\n",\ "catch { source ${ngdir}/trafoapp/smallmodels.tcl }\n",\ "\n",\ "catch { \n",\ " source ${ngdir}/ngtcltk/ngshell.tcl\n",\ " source ${ngdir}/ngtcltk/ngtesting.tcl\n",\ "}\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ "\n",\ 0}; netgen-4.9.13/ng/demoview.hpp0000644000175000001440000000516111240003500012725 00000000000000#ifndef FILE_DEMOVIEW #define FILE_DEMOVIEW /*********************************************************************/ /* File: demoview.hpp */ /* Author: Robert, Joachim */ /* Date: 6. Mar. 2003 */ /*********************************************************************/ using namespace netgen; enum DEMOVIEW_TOKEN_TYPE { DTOK_MINUS = '-', DTOK_LP = '(', DTOK_RP = ')', DTOK_LSP = '[', DTOK_RSP = ']', DTOK_EQU = '=', DTOK_COMMA = ',', DTOK_SEMICOLON = ';', DTOK_COLON = ':', DTOK_PLUS = '+', DTOK_NUM = 100, DTOK_STRING, DTOK_TIME, DTOK_CAMPOS, DTOK_CAMPOINT, DTOK_CAMUP, DTOK_END }; struct demoview_kwstruct { DEMOVIEW_TOKEN_TYPE kw; const char * name; }; class DemoScanner { DEMOVIEW_TOKEN_TYPE token; double num_value; string string_value; int linenum; ifstream * scanin; public: DemoScanner (ifstream & ascanin); DEMOVIEW_TOKEN_TYPE GetToken() const { return token; } double GetNumValue() const { return num_value; } const string & GetStringValue() const { return string_value; } void ReadNext(); void Error (const string & err); }; void ParseChar (DemoScanner & scan, char ch); double ParseNumber(DemoScanner & scan); Vec<3> ParseVector (DemoScanner & scan); template class InterpolationPoint { double t; S s; public: InterpolationPoint() {}; ~InterpolationPoint() {}; double GetT() const { return t; }; S GetS() const { return s; }; void SetTS(double at, S as) { t = at; s = as; }; InterpolationPoint & operator= (const InterpolationPoint & ip2) { SetTS (ip2.t, ip2.s); return (*this); }; }; template class InterpolationSpline { protected: // Array < InterpolationPoint[3] > ip; class intpts { public: InterpolationPoint pts[3]; InterpolationPoint & operator[](int i) { return pts[i]; } }; Array < intpts > ip; int finished; public: InterpolationSpline() : finished(0) {}; InterpolationSpline( S s1 ) : finished(0) { AddSpline (-1e99, -1e99, -1e99, s1, s1, s1); // InterpolationSpline(); } ~InterpolationSpline() {}; void AddSpline(double t1, double t2, double t3, S s1, S s2, S s3); S Evaluate (double t); int IsFinished() const { return finished; } }; class DemoView { InterpolationSpline< Vec<3> > campos; InterpolationSpline< Vec<3> > campoint; InterpolationSpline< Vec<3> > camup; public: DemoView (const char * filename); ~DemoView (); int SetTime (double time); }; #endif netgen-4.9.13/ng/parallelinterface.cpp0000644000175000001440000000774611240003500014571 00000000000000#ifdef PARALLEL #include #include #include "../libsrc/include/parallelinterface.hpp" namespace netgen { extern AutoPtr mesh; using namespace netgen; // int NgPar_Glob2Loc_SurfEl ( int globnum ) // { // return mesh->GetParallelTopology().Glob2Loc_SurfEl(globnum+1) - 1; // } // int NgPar_Glob2Loc_VolEl ( int globnum ) // { // return mesh->GetParallelTopology().Glob2Loc_VolEl(globnum+1) - 1; // } // int NgPar_Glob2Loc_Segm ( int globnum ) // { // return mesh->GetParallelTopology().Glob2Loc_Segm(globnum+1) - 1; // } // int NgPar_Glob2Loc_Vert ( int globnum ) // { // return mesh->GetParallelTopology().Glob2Loc_Vert(globnum+1) -1; // } int NgPar_GetLoc2Glob_VolEl ( int locnum ) { return mesh -> GetParallelTopology().GetLoc2Glob_VolEl ( locnum+1) -1; } // gibt anzahl an distant pnums zurueck // * pnums entspricht ARRAY int NgPar_GetDistantNodeNums ( int nodetype, int locnum, int * distnums ) { int size; switch ( nodetype ) { case 0: size = mesh->GetParallelTopology().GetDistantPNums( locnum+1, distnums ); break; case 1: size = mesh->GetParallelTopology().GetDistantEdgeNums( locnum+1, distnums ); break; case 2: size = mesh->GetParallelTopology().GetDistantFaceNums( locnum+1, distnums ); break; case 3: size = mesh->GetParallelTopology().GetDistantElNums( locnum+1, distnums ); break; default: cerr << "NgPar_GetDistantNodeNums() Unknown nodetype " << nodetype << endl; size = -1; } // 0 - based for ( int i = 0; i < size; i++ ) distnums[2*i+1]--; return size; } int NgPar_GetNDistantNodeNums ( int nodetype, int locnum ) { switch ( nodetype ) { case 0: return mesh->GetParallelTopology().GetNDistantPNums( locnum+1 ); case 1: return mesh->GetParallelTopology().GetNDistantEdgeNums( locnum+1 ); case 2: return mesh->GetParallelTopology().GetNDistantFaceNums( locnum+1 ); case 3: return mesh->GetParallelTopology().GetNDistantElNums( locnum+1 ); } return -1; } int NgPar_GetDistantPNum ( int proc, int locpnum ) { return mesh->GetParallelTopology().GetDistantPNum( proc, locpnum+1) - 1; } int NgPar_GetDistantEdgeNum ( int proc, int locpnum ) { return mesh->GetParallelTopology().GetDistantEdgeNum( proc, locpnum+1) - 1; } int NgPar_GetDistantFaceNum ( int proc, int locpnum ) { return mesh->GetParallelTopology().GetDistantFaceNum (proc, locpnum+1 ) - 1; } int NgPar_GetDistantElNum ( int proc, int locelnum ) { return mesh->GetParallelTopology().GetDistantElNum (proc, locelnum+1 ) - 1; } bool NgPar_IsExchangeFace ( int fnr ) { return (mesh->GetParallelTopology().GetNDistantFaceNums( fnr+1 ) > 0); // return mesh->GetParallelTopology().IsExchangeFace ( fnr+1 ); } bool NgPar_IsExchangeVert ( int vnum ) { return (mesh->GetParallelTopology().GetNDistantPNums( vnum+1 ) > 0); // return mesh->GetParallelTopology().IsExchangeVert ( vnum+1 ); } bool NgPar_IsExchangeEdge ( int ednum ) { return (mesh->GetParallelTopology().GetNDistantEdgeNums( ednum+1 ) > 0); // return mesh->GetParallelTopology().IsExchangeEdge ( ednum+1 ); } bool NgPar_IsExchangeElement ( int elnum ) { return (mesh->GetParallelTopology().GetNDistantElNums( elnum+1 ) > 0); // return mesh->GetParallelTopology().IsExchangeElement ( elnum+1 ); } void NgPar_PrintParallelMeshTopology () { mesh -> GetParallelTopology().Print (); } bool NgPar_IsElementInPartition ( const int elnum, const int dest ) { return mesh -> GetParallelTopology().IsElementInPartition ( elnum+1, dest ); } bool NgPar_IsGhostFace ( const int facenum ) { return mesh -> GetParallelTopology().IsGhostFace ( facenum+1); } bool NgPar_IsGhostEdge ( const int edgenum ) { return mesh -> GetParallelTopology().IsGhostEdge ( edgenum+1); } } #endif netgen-4.9.13/ng/ngappinit.cpp0000644000175000001440000002623311375223126013116 00000000000000/* The main function of netgen. This file is a modification of tkAppInit.c from the Tcl/Tk package */ #include #include "incvis.hpp" #include #ifdef LINUX // #include #endif /* #ifndef WIN32 #include #endif */ #ifdef PARALLEL #include namespace netgen { int id, ntasks; MPI_Group MPI_HIGHORDER_WORLD; MPI_Comm MPI_HIGHORDER_COMM; } #endif #include "parallelfunc.hpp" namespace netgen { #include "writeuser.hpp" extern string ngdir; } using netgen::parameters; using netgen::ngdir; using netgen::verbose; using netgen::Array; using netgen::RegisterUserFormats; /* * The following variable is a special hack that is needed in order for * Sun shared libraries to be used for Tcl. */ // extern "C" int matherr(); // int *tclDummyMathPtr = (int *) matherr; extern "C" int Ng_ServerSocketManagerInit (int port); extern "C" int Ng_ServerSocketManagerRun (void); bool nodisplay = false; bool shellmode = false; /* * * The Netgen main function * */ int main(int argc, char ** argv) { #ifdef PARALLEL // parallel profiling #pragma pomp inst init MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &netgen::ntasks); MPI_Comm_rank(MPI_COMM_WORLD, &netgen::id); MPI_Group MPI_GROUP_WORLD; int n_ho = netgen::ntasks - 1; int * process_ranks = new int[netgen::ntasks-1]; for ( int i = 0; i < netgen::ntasks-1; i++ ) process_ranks[i] = i+1; MPI_Comm_group ( MPI_COMM_WORLD, &MPI_GROUP_WORLD); MPI_Group_incl ( MPI_GROUP_WORLD, n_ho, process_ranks, & netgen::MPI_HIGHORDER_WORLD); MPI_Comm_create ( MPI_COMM_WORLD, netgen::MPI_HIGHORDER_WORLD, & netgen::MPI_HIGHORDER_COMM); #pragma pomp inst begin(main) #endif if ( netgen::id == 0 ) { cout << "NETGEN-" << PACKAGE_VERSION << endl; cout << "Developed at RWTH Aachen University, Germany" << endl << "and Johannes Kepler University Linz, Austria" << endl; #ifdef OCCGEOMETRY cout << "Including OpenCascade geometry kernel" << endl; #endif #ifdef ACIS cout << "Including ACIS geometry kernel" << endl; #endif #ifdef LINUX //feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW); //feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW); //cout << "Handle Floating Point Exceptions: " << fegetexcept() << endl; #endif #ifdef DEBUG cout << "You are running the debug version !" << endl; #endif #ifdef USE_SUPERLU cout << "Including sparse direct solver SuperLU by Lawrence Berkeley National Laboratory" << endl; #endif #ifdef PARALLEL cout << "Including MPI " << endl; cout << "Using " << netgen::ntasks << " processor" << ((netgen::ntasks > 1) ? "s " : " ") << endl; #endif } else { ;// nodisplay = true; } // command line arguments: for (int i = 1; i < argc; i++) { if (argv[i][0] == '-') parameters.SetCommandLineFlag (argv[i]); else parameters.SetFlag ("geofile", argv[i]); } if (getenv ("NETGENDIR") && strlen (getenv ("NETGENDIR"))) ngdir = getenv ("NETGENDIR"); else ngdir = "."; verbose = parameters.GetDefineFlag ("V"); if (verbose) cout << "NETGENDIR = " << ngdir << endl; if ( netgen::id == 0 ) { if (parameters.StringFlagDefined ("testout")) netgen::testout = new ofstream (parameters.GetStringFlag ("testout", "test.out")); #ifdef SOCKETS Ng_ServerSocketManagerInit(static_cast(parameters.GetNumFlag("serversocket",-1))); if(parameters.GetNumFlag("serversocket",-1) > 0 && !parameters.GetDefineFlag("display")) nodisplay = true; #endif if(parameters.GetDefineFlag("batchmode")) nodisplay = true; if(parameters.GetDefineFlag("shellmode")) { nodisplay = true; shellmode = true; } Tcl_FindExecutable(NULL); // initialize application Tcl_Interp * myinterp = Tcl_CreateInterp (); if (Tcl_AppInit (myinterp) == TCL_ERROR) { cerr << "Exit Netgen due to initialization problem" << endl; exit (1); } // parse tcl-script int errcode; bool internaltcl = false; if (shellmode) internaltcl = false; #ifdef PARALLEL internaltcl = false; #endif if (verbose) { cout << "Tcl header version = " << TCL_PATCH_LEVEL << endl; Tcl_Eval (myinterp, "puts \"Tcl runtime version = [info patchlevel] \";"); } if (parameters.GetDefineFlag ("internaltcl")) internaltcl=true; if (parameters.GetDefineFlag ("externaltcl")) internaltcl=false; if (internaltcl) { if (verbose) cout << "using internal Tcl-script" << endl; // connect to one string extern const char * ngscript[]; const char ** hcp = ngscript; int len = 0; while (*hcp) len += strlen (*hcp++); char * tr1 = new char[len+1]; *tr1 = 0; hcp = ngscript; char * tt1 = tr1; while (*hcp) { strcat (tt1, *hcp); tt1 += strlen (*hcp++); } errcode = Tcl_Eval (myinterp, tr1); delete [] tr1; } else { string startfile = ngdir + "/ng.tcl"; if (verbose) cout << "Load Tcl-script from " << startfile << endl; errcode = Tcl_EvalFile (myinterp, (char*)startfile.c_str()); } if (errcode) { cout << "Error in Tcl-Script:" << endl; // cout << "result = " << myinterp->result << endl; cout << "result = " << Tcl_GetStringResult (myinterp) << endl; // cout << "in line " << myinterp->errorLine << endl; cout << "\nMake sure to set environment variable NETGENDIR to directory containing ng.tcl" << endl; exit (1); } // lookup user file formats and insert into format list: Array userformats; Array extensions; RegisterUserFormats (userformats, extensions); ostringstream fstr; tcl_const char * exportft = Tcl_GetVar (myinterp, "exportfiletype", 0); for (int i = 1; i <= userformats.Size(); i++) { fstr << ".ngmenu.file.filetype add radio -label \"" << userformats.Get(i) << "\" -variable exportfiletype\n"; fstr << "lappend meshexportformats { {" << userformats.Get(i) << "} {" << extensions.Get(i) << "} }\n"; } Tcl_Eval (myinterp, (char*)fstr.str().c_str()); // Tcl_SetVar (myinterp, "exportfiletype", "Neutral Format", 0); Tcl_SetVar (myinterp, "exportfiletype", exportft, 0); // For adding an application, parse the file here, // and call the init-procedure below // #define DEMOAPP #ifdef DEMOAPP Tcl_EvalFile (myinterp, "demoapp/demoapp.tcl"); #endif #ifdef ADDON Tcl_EvalFile (myinterp, "addon/addon.tcl"); #endif #ifdef SOCKETS Ng_ServerSocketManagerRun(); #endif // start event-loop Tk_MainLoop(); Tcl_DeleteInterp (myinterp); #ifdef PARALLEL #pragma pomp inst altend(main) // MPI beenden MPI_Barrier(MPI_COMM_WORLD); MPI_Finalize(); #endif Tcl_Exit(0); } #ifdef PARALLEL else { // main for parallel processors ParallelRun(); #pragma pomp inst end(main) // MPI beenden MPI_Barrier(MPI_COMM_WORLD); MPI_Finalize(); } #endif return 0; } /* extern "C" int Tix_Init (Tcl_Interp * interp); extern "C" int Itcl_Init (Tcl_Interp * interp); extern "C" int Itk_Init (Tcl_Interp * interp); */ extern "C" int Ng_Init (Tcl_Interp * interp); extern "C" int Ng_Vis_Init (Tcl_Interp * interp); // extern Tcl_PackageInitProc * Tk_SafeInit; /* * * Initialize packages * */ // extern "C" int NGSolve_Init (Tcl_Interp * interp); int Tcl_AppInit(Tcl_Interp * interp) { if (Tcl_Init(interp) == TCL_ERROR) { cerr << "Problem in Tcl_Init: " << endl; cout << "result = " << Tcl_GetStringResult (interp) << endl; // cerr << interp->result << endl; // return TCL_ERROR; } if (!nodisplay && Tk_Init(interp) == TCL_ERROR) { cerr << "Problem in Tk_Init: " << endl; cout << "result = " << Tcl_GetStringResult (interp) << endl; // cerr << interp->result << endl; // return TCL_ERROR; } // if ITcl and ITk are installed on the system, then // they must also be initialized /* if (Itcl_Init(interp) == TCL_ERROR) { cerr << "Problem in Itcl_Init: " << endl; cerr << interp->result << endl; // return TCL_ERROR; } if (Itk_Init(interp) == TCL_ERROR) { cerr << "Problem in Itk_Init: " << endl; cerr << interp->result << endl; // return TCL_ERROR; } */ /* if (!nodisplay && Tix_Init(interp) == TCL_ERROR) { cerr << "Problem in Tix_Init: " << endl; cerr << interp->result << endl; // return TCL_ERROR; } */ if (Ng_Init(interp) == TCL_ERROR) { cerr << "Problem in Ng_Init: " << endl; cout << "result = " << Tcl_GetStringResult (interp) << endl; // cerr << interp->result << endl; // return TCL_ERROR; } if (!nodisplay && Ng_Vis_Init(interp) == TCL_ERROR) { cerr << "Problem in Ng_Vis_Init: " << endl; cout << "result = " << Tcl_GetStringResult (interp) << endl; // cerr << interp->result << endl; // return TCL_ERROR; } /* if (NGSolve_Init(interp) == TCL_ERROR) return TCL_ERROR; */ #ifdef DEMOAPP extern int DemoApp_Init (Tcl_Interp * interp); if (DemoApp_Init(interp) == TCL_ERROR) { return TCL_ERROR; } #endif #ifdef ADDON extern int AddOn_Init (Tcl_Interp * interp); if (AddOn_Init(interp) == TCL_ERROR) { return TCL_ERROR; } #endif #ifdef METIS_OLD extern int NgMetis_Init (Tcl_Interp * interp); if (NgMetis_Init(interp) == TCL_ERROR) { return TCL_ERROR; } #endif #ifdef TRAFO // extern int Trafo_Init (Tcl_Interp * interp); // if (Trafo_Init(interp) == TCL_ERROR) // { // cerr << "Problem in Trafo_Init: " << endl; // cerr << interp->result << endl; // return TCL_ERROR; // } #endif #ifdef EBGELAST extern int EBGElast_Init (Tcl_Interp * interp); if(EBGElast_Init(interp) == TCL_ERROR) { cerr << "Problem in EBGElast_Init: " << endl; cerr << interp->result << endl; return TCL_ERROR; } #endif #ifdef SMALLTRAFO extern int SmallModels_Init (Tcl_Interp * interp); if(SmallModels_Init(interp) == TCL_ERROR) { cerr << "Problem in SmallModel_Init: " << endl; cerr << interp->result << endl; return TCL_ERROR; } #endif #ifdef SOCKETS extern int Ng_Socket_Init (Tcl_Interp * interp); if ( Ng_Socket_Init(interp) == TCL_ERROR) { cerr << "Problem in Ng_Socket_Init: " << endl; cerr << interp->result << endl; return TCL_ERROR; } #endif #ifdef ZUGSTANGE extern int Zugstange_Init (Tcl_Interp * interp); if (Zugstange_Init(interp) == TCL_ERROR) { cerr << "Problem in Zugstange_Init: " << endl; cerr << interp->result << endl; return TCL_ERROR; } #endif Tcl_StaticPackage(interp, "Tk", Tk_Init, 0); return TCL_OK; } netgen-4.9.13/ng/demoview.cpp0000644000175000001440000002042711240003500012722 00000000000000/*********************************************************************/ /* File: demoview.cpp */ /* Author: Robert, Joachim */ /* Date: 6. Mar. 2003 */ /*********************************************************************/ #include //#include #include #include #include #include #include #include #include #include "incvis.hpp" #include namespace netgen { extern VisualScene *vs; #include "demoview.hpp" /* static demokwstruct defkw[] = { { TOK_TIME, "t" }, { TOK_CAMPOS, "camerapos" }, { TOK_CAMPOINT, "camerapointto" }, { TOK_CAMUP, "cameraup" } }; */ static demoview_kwstruct demoview_defkw[] = { { DTOK_TIME, "t" }, { DTOK_CAMPOS, "camerapos" }, { DTOK_CAMPOINT, "camerapointto" }, { DTOK_CAMUP, "cameraup" } }; DemoScanner :: DemoScanner (ifstream & ascanin) { scanin = &ascanin; token = DTOK_END; num_value = 0; linenum = 1; } void DemoScanner :: ReadNext () { char ch; // whitespaces ueberspringen do { scanin->get(ch); if (ch == '\n') linenum++; // end of file reached if (scanin->eof()) { token = DTOK_END; return; } // skip comment line if (ch == '#') { while (ch != '\n') { scanin->get(ch); if (scanin->eof()) { token = DTOK_END; return; } } linenum++; } } while (isspace(ch)); switch (ch) { case '(': case ')': case '[': case ']': case '-': case ':': case '=': case ',': case ';': case '+': { token = DEMOVIEW_TOKEN_TYPE (ch); break; } default: { if (isdigit (ch) || ch == '.') { scanin->putback (ch); (*scanin) >> num_value; token = DTOK_NUM; return; } if (isalpha (ch)) { string_value = string (1, ch); scanin->get(ch); while (isalnum(ch)) { string_value += ch; scanin->get(ch); } scanin->putback (ch); } int nr = 0; while (demoview_defkw[nr].kw) { if (string_value == demoview_defkw[nr].name) { token = demoview_defkw[nr].kw; return; } nr++; } token = DTOK_STRING; } } } void DemoScanner :: Error (const string & err) { stringstream errstr; errstr << "Parsing error in line " << linenum << ": " << endl << err << endl; throw string(errstr.str()); } void ParseChar (DemoScanner & scan, char ch) { char str[2]; str[0] = ch; str[1] = 0; if (scan.GetToken() != DEMOVIEW_TOKEN_TYPE(ch)) scan.Error (string ("token '") + string(str) + string("' expected")); scan.ReadNext(); } double ParseNumber(DemoScanner & scan) { if (scan.GetToken() == '-') { scan.ReadNext(); return -ParseNumber (scan); } if (scan.GetToken() != DTOK_NUM) scan.Error ("number expected"); double val = scan.GetNumValue(); scan.ReadNext(); return val; } Vec<3> ParseVector (DemoScanner & scan) { Vec<3> s; s(0) = ParseNumber (scan); ParseChar (scan, ','); s(1) = ParseNumber (scan); ParseChar (scan, ','); s(2) = ParseNumber (scan); return s; } void ParseConstLineOrSpline (DemoScanner & scan, double * t, Vec<3> * s) { int np = 1; scan.ReadNext(); ParseChar (scan, '('); t[0] = ParseNumber (scan)*1000; ParseChar (scan, ':'); s[0] = ParseVector (scan); if (scan.GetToken() != DTOK_RP && scan.GetToken() != DTOK_SEMICOLON) scan.Error (") or ; expected"); if (scan.GetToken() == DTOK_SEMICOLON) { np++; scan.ReadNext(); t[1] = ParseNumber (scan)*1000; ParseChar (scan, ':'); s[1] = ParseVector (scan); if (scan.GetToken() != DTOK_RP && scan.GetToken() != DTOK_SEMICOLON) scan.Error (") or ; expected"); if (scan.GetToken() == DTOK_SEMICOLON) { np++; scan.ReadNext(); t[2] = ParseNumber (scan)*1000; ParseChar (scan, ':'); s[2] = ParseVector (scan); ParseChar (scan, ')'); ParseChar (scan, ';'); } else if (scan.GetToken() == DTOK_RP) { scan.ReadNext(); ParseChar (scan, ';'); } } else if (scan.GetToken() == DTOK_RP) { scan.ReadNext(); ParseChar (scan, ';'); } if (np == 1) // constant spline { t[1] = t[2] = t[0]; s[1] = s[2] = s[0]; } if (np == 2) // linear spline { t[2] = t[1]; t[1] = 0.5*(t[0] + t[2]); s[2] = s[1]; s[1] = 0.5*(s[0] + s[2]); } } template void InterpolationSpline :: AddSpline(double t1, double t2, double t3, S s1, S s2, S s3) { int pos, i, j; // find pos to insert interpotation point for (pos = 0; pos < ip.Size() && ip[pos][0].GetT() < t1; pos++) ; ip.SetSize( ip.Size()+1 ); for (i = ip.Size()-2; i >= pos; i--) for (j = 0; j < 3; j++) ip[i+1][j] = ip[i][j]; ip[pos][0].SetTS (t1, s1); ip[pos][1].SetTS (t2, s2); ip[pos][2].SetTS (t3, s3); } template S InterpolationSpline :: Evaluate (double t) { if (t < ip[0][0].GetT()) return (ip[0][0].GetS()); if (t > ip[ip.Size()-1][2].GetT()) { finished = 1; return (ip[ip.Size()-1][2].GetS()); } int pos; for (pos = 0; pos < ip.Size() && t >= ip[pos][0].GetT(); pos++) ; pos--; if (t >= ip[pos][0].GetT() && t <= ip[pos][2].GetT()) { double t0 = ip[pos][0].GetT(); double t1 = ip[pos][2].GetT(); double t01 = (t-t0)/(t1-t0); double b1, b2, b3, w; b1 = (1-t01)*(1-t01); b2 = sqrt(2.0) * t01 * (1-t01); b3 = t01 * t01; w = b1 + b2 + b3; return ( (1/w) * (b1 * ip[pos][0].GetS() + b2 * ip[pos][1].GetS() + b3 * ip[pos][2].GetS()) ); } else return (ip[pos][2].GetS()); } DemoView :: DemoView (const char * filename) : campos( Vec<3>(5,0,0) ), campoint ( Vec<3>(0,0,0) ), camup ( Vec<3>(0,0,1) ) { double time = 0; ifstream istr; istr.open(filename); DemoScanner scan(istr); double t[3]; Vec<3> s[3]; scan.ReadNext(); try { while (1) { if (scan.GetToken() == DTOK_END) break; if (scan.GetToken() == DTOK_CAMPOS) { ParseConstLineOrSpline (scan, &t[0], &s[0]); campos.AddSpline (time+t[0], time+t[1], time+t[2], s[0], s[1], s[2]); } else if (scan.GetToken() == DTOK_CAMUP) { ParseConstLineOrSpline (scan, &t[0], &s[0]); camup.AddSpline (time+t[0], time+t[1], time+t[2], s[0], s[1], s[2]); } else if (scan.GetToken() == DTOK_CAMPOINT) { ParseConstLineOrSpline (scan, &t[0], &s[0]); campoint.AddSpline (time+t[0], time+t[1], time+t[2], s[0], s[1], s[2]); } else if (scan.GetToken() == DTOK_TIME) { scan.ReadNext(); if (scan.GetToken() != DTOK_EQU && scan.GetToken() != DTOK_PLUS) scan.Error ("= or += expected"); if (scan.GetToken() == DTOK_EQU) { scan.ReadNext(); time = ParseNumber (scan)*1000; ParseChar (scan, ';'); } else if (scan.GetToken() == DTOK_PLUS) { scan.ReadNext(); ParseChar (scan, '='); time += ParseNumber (scan)*1000; ParseChar (scan, ';'); } } else { cout << "read unidentified token " << scan.GetToken() << " string = " << scan.GetStringValue() << endl; scan.ReadNext(); } } } catch (string errstr) { cout << "caught error " << errstr << endl; } } DemoView :: ~DemoView () { ; } int DemoView :: SetTime (double time) { /* cout << "time = " << time << endl; cout << "campos : " << campos.Evaluate (time) << endl; cout << "campoint: " << campoint.Evaluate (time) << endl; cout << "camup : " << camup.Evaluate (time) << endl; */ vs -> LookAt ( Point<3>( campos.Evaluate (time)), Point<3>(campoint.Evaluate (time)), Point<3>( camup.Evaluate (time)) ); if (campos.IsFinished() && campoint.IsFinished() && camup.IsFinished()) { return -1; } return 0; } } netgen-4.9.13/ng/nginterface_v2.cpp0000644000175000001440000001523111374147446014026 00000000000000#include #include #include #include #include #ifdef OCCGEOMETRY #include #endif #ifdef ACIS #include #endif #ifdef SOCKETS #include "../sockets/sockets.hpp" #endif #ifndef NOTCL #include #endif #include "nginterface.h" #include "nginterface_v2.hpp" // #include // #include namespace netgen { #include "writeuser.hpp" extern AutoPtr mesh; #ifndef NOTCL extern VisualSceneMesh vsmesh; extern Tcl_Interp * tcl_interp; #endif extern AutoPtr geometry2d; extern AutoPtr geometry; extern STLGeometry * stlgeometry; #ifdef OCCGEOMETRY extern OCCGeometry * occgeometry; #endif #ifdef ACIS extern ACISGeometry * acisgeometry; #endif #ifdef OPENGL extern VisualSceneSolution vssolution; #endif extern CSGeometry * ParseCSG (istream & istr); #ifdef SOCKETS extern AutoPtr clientsocket; //extern Array< AutoPtr < ServerInfo > > servers; extern Array< ServerInfo* > servers; #endif } namespace netgen { template <> int DLL_HEADER Ng_GetNElements<1> () { return mesh->GetNSeg(); } template <> DLL_HEADER int Ng_GetNElements<2> () { return mesh->GetNSE(); } template <> DLL_HEADER int Ng_GetNElements<3> () { return mesh->GetNE(); } template <> DLL_HEADER Ng_Element Ng_GetElement<1> (int nr) { const Segment & el = mesh->LineSegment (SegmentIndex(nr)); Ng_Element ret; ret.type = NG_ELEMENT_TYPE(el.GetType()); ret.points.num = el.GetNP(); ret.points.ptr = (int*)&(el[0]); ret.vertices.num = 2; ret.vertices.ptr = (int*)&(el[0]); ret.edges.num = 1; ret.edges.ptr = mesh->GetTopology().GetSegmentElementEdgesPtr (nr); ret.faces.num = 0; ret.faces.ptr = NULL; return ret; } template <> DLL_HEADER Ng_Element Ng_GetElement<2> (int nr) { const Element2d & el = mesh->SurfaceElement (SurfaceElementIndex (nr)); Ng_Element ret; ret.type = NG_ELEMENT_TYPE(el.GetType()); ret.points.num = el.GetNP(); ret.points.ptr = (int*)&el[0]; ret.vertices.num = el.GetNV(); ret.vertices.ptr = (int*)&(el[0]); ret.edges.num = MeshTopology::GetNEdges (el.GetType()); ret.edges.ptr = mesh->GetTopology().GetSurfaceElementEdgesPtr (nr); ret.faces.num = MeshTopology::GetNFaces (el.GetType()); ret.faces.ptr = mesh->GetTopology().GetSurfaceElementFacesPtr (nr); return ret; } template <> DLL_HEADER Ng_Element Ng_GetElement<3> (int nr) { const Element & el = mesh->VolumeElement (ElementIndex (nr)); Ng_Element ret; ret.type = NG_ELEMENT_TYPE(el.GetType()); ret.points.num = el.GetNP(); ret.points.ptr = (int*)&el[0]; ret.vertices.num = el.GetNV(); ret.vertices.ptr = (int*)&(el[0]); ret.edges.num = MeshTopology::GetNEdges (el.GetType()); ret.edges.ptr = mesh->GetTopology().GetElementEdgesPtr (nr); ret.faces.num = MeshTopology::GetNFaces (el.GetType()); ret.faces.ptr = mesh->GetTopology().GetElementFacesPtr (nr); return ret; } DLL_HEADER Ng_Point Ng_GetPoint (int nr) { Ng_Point ret; ret.pt = &mesh->Point(nr + PointIndex::BASE)(0); return ret; } template <> DLL_HEADER int Ng_GetElementIndex<1> (int nr) { return (*mesh)[SegmentIndex(nr)].si; } template <> DLL_HEADER int Ng_GetElementIndex<2> (int nr) { int ind = (*mesh)[SurfaceElementIndex(nr)].GetIndex(); return mesh->GetFaceDescriptor(ind).BCProperty(); } template <> DLL_HEADER int Ng_GetElementIndex<3> (int nr) { return (*mesh)[ElementIndex(nr)].GetIndex(); } template <> DLL_HEADER void Ng_MultiElementTransformation<3,3> (int elnr, int npts, const double * xi, size_t sxi, double * x, size_t sx, double * dxdxi, size_t sdxdxi) { mesh->GetCurvedElements().CalcMultiPointElementTransformation (elnr, npts, xi, sxi, x, sx, dxdxi, sdxdxi); } template <> DLL_HEADER void Ng_MultiElementTransformation<2,2> (int elnr, int npts, const double * xi, size_t sxi, double * x, size_t sx, double * dxdxi, size_t sdxdxi) { mesh->GetCurvedElements().CalcMultiPointSurfaceTransformation<2> (elnr, npts, xi, sxi, x, sx, dxdxi, sdxdxi); } template <> DLL_HEADER void Ng_MultiElementTransformation<2,3> (int elnr, int npts, const double * xi, size_t sxi, double * x, size_t sx, double * dxdxi, size_t sdxdxi) { mesh->GetCurvedElements().CalcMultiPointSurfaceTransformation<3> (elnr, npts, xi, sxi, x, sx, dxdxi, sdxdxi); } template <> DLL_HEADER void Ng_MultiElementTransformation<1,2> (int elnr, int npts, const double * xi, size_t sxi, double * x, size_t sx, double * dxdxi, size_t sdxdxi) { for (int ip = 0; ip < npts; ip++) { Point<3> xg; Vec<3> dx; mesh->GetCurvedElements().CalcSegmentTransformation (xi[ip*sxi], elnr, xg, dx); if (x) for (int i = 0; i < 2; i++) x[ip*sx+i] = xg(i); if (dxdxi) for (int i=0; i<2; i++) dxdxi[ip*sdxdxi+i] = dx(i); } } template <> DLL_HEADER void Ng_MultiElementTransformation<1,1> (int elnr, int npts, const double * xi, size_t sxi, double * x, size_t sx, double * dxdxi, size_t sdxdxi) { cout << "1D not supported" << endl; } template <> DLL_HEADER int Ng_GetNNodes<1> () { return mesh->GetTopology().GetNEdges(); } template <> DLL_HEADER int Ng_GetNNodes<2> () { return mesh->GetTopology().GetNFaces(); } template <> DLL_HEADER Ng_Node<1> Ng_GetNode<1> (int nr) { Ng_Node<1> node; node.vertices.ptr = mesh->GetTopology().GetEdgeVerticesPtr(nr); return node; } template <> DLL_HEADER Ng_Node<2> Ng_GetNode<2> (int nr) { Ng_Node<2> node; node.vertices.ptr = mesh->GetTopology().GetFaceVerticesPtr(nr); node.vertices.nv = (node.vertices.ptr[3] == 0) ? 3 : 4; return node; } } netgen-4.9.13/ng/netgen.ocf0000644000175000001440000000134311262561732012370 00000000000000# Netgen Mesher # Boundary Condition Colour Profile # # Name: netgen.ocf # # Description: Netgen default colour # profile file for colour based automatic # assignment of boundary condition numbers # # Format: # [boundary_colours] (mandatory keyword) # # # # .... # .... # NOTE: # * Currently, the default Boundary # Condition number assigned to faces without # any colour defined is "1" # * Boundary Condition number "0" is invalid, # and should not be used boundary_colours 7 2 0.0000 0.0000 0.0000 3 1.0000 0.0000 0.0000 4 0.0000 0.0000 1.0000 5 1.0000 1.0000 0.0000 6 0.0000 1.0000 1.0000 7 1.0000 0.0000 1.0000 8 1.0000 1.0000 1.0000 netgen-4.9.13/ng/ngicon.tcl0000644000175000001440000001000411240003500012346 00000000000000set 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" }; } netgen-4.9.13/ng/nginterface.cpp0000644000175000001440000014473211364062142013414 00000000000000#include #include #include #include #include #ifdef OCCGEOMETRY #include #endif #ifdef ACIS #include #endif #ifdef SOCKETS #include "../sockets/sockets.hpp" #endif #ifndef NOTCL #include #endif #include "nginterface.h" namespace netgen { #include "writeuser.hpp" extern AutoPtr mesh; #ifndef NOTCL extern VisualSceneMesh vsmesh; extern Tcl_Interp * tcl_interp; #endif extern AutoPtr geometry2d; extern AutoPtr geometry; extern STLGeometry * stlgeometry; #ifdef OCCGEOMETRY extern OCCGeometry * occgeometry; #endif #ifdef ACIS extern ACISGeometry * acisgeometry; #endif #ifdef OPENGL extern VisualSceneSolution vssolution; #endif extern CSGeometry * ParseCSG (istream & istr); #ifdef SOCKETS extern AutoPtr clientsocket; //extern Array< AutoPtr < ServerInfo > > servers; extern Array< ServerInfo* > servers; #endif } using namespace netgen; /* #ifdef _MSC_VER // Philippose - 30/01/2009 // MSVC Express Edition Support #ifdef MSVC_EXPRESS // #include static pthread_t meshingthread; void RunParallel ( void * (*fun)(void *), void * in) { if (netgen::mparam.parthread) { pthread_attr_t attr; pthread_attr_init (&attr); // the following call can be removed if not available: pthread_attr_setstacksize(&attr, 1000000); //pthread_create (&meshingthread, &attr, fun, NULL); pthread_create (&meshingthread, &attr, fun, in); } else fun (in); } #else // Using MS VC++ Standard / Enterprise / Professional edition // Afx - Threads need different return - value: static void* (*sfun)(void *); unsigned int fun2 (void * val) { sfun (val); return 0; } void RunParallel ( void* (*fun)(void *), void * in) { sfun = fun; if (netgen::mparam.parthread) AfxBeginThread (fun2, in); //AfxBeginThread (fun2, NULL); else fun (in); } #endif // #ifdef MSVC_EXPRESS #else // For #ifdef _MSC_VER // #include static pthread_t meshingthread; void RunParallel ( void * (*fun)(void *), void * in) { if (netgen::mparam.parthread) { pthread_attr_t attr; pthread_attr_init (&attr); // the following call can be removed if not available: pthread_attr_setstacksize(&attr, 1000000); //pthread_create (&meshingthread, &attr, fun, NULL); pthread_create (&meshingthread, &attr, fun, in); } else fun (in); } #endif // #ifdef _MSC_VER */ void Ng_LoadGeometry (const char * filename) { // if (printmessage_importance>0) // cout << "CALLED NG LOAD GEOMETRY" << endl; geometry.Reset (new CSGeometry ()); geometry2d.Reset (); #ifdef OCCGEOMETRY delete occgeometry; occgeometry = 0; #endif #ifdef ACIS delete acisgeometry; acisgeometry = 0; #endif // he: if filename is empty, return // can be used to reset geometry if (strcmp(filename,"")==0) return; PrintMessage (1, "Load geometry from file ", filename); ifstream infile (filename); if ((strcmp (&filename[strlen(filename)-3], "geo") == 0) || (strcmp (&filename[strlen(filename)-3], "GEO") == 0) || (strcmp (&filename[strlen(filename)-3], "Geo") == 0)) { geometry.Reset( netgen::ParseCSG(infile) ); if (!geometry) { geometry.Reset (new CSGeometry ()); //throw NgException ("input file not found"); cerr << "Error: input file \"" << filename << "\" not found" << endl; } geometry -> FindIdenticSurfaces(1e-6); #ifdef PARALLEL int id, rc, ntasks; MPI_Comm_size(MPI_COMM_WORLD, &ntasks); MPI_Comm_rank(MPI_COMM_WORLD, &id); if ( id > 0 ) { geometry->CalcTriangleApproximation ( geometry->BoundingBox(), 0.001, 20 ); return; } #endif Box<3> box (geometry->BoundingBox()); #ifdef NOTCL double detail = 0.001; double facets = 20; geometry->CalcTriangleApproximation(box, detail, facets); #else double detail = atof (Tcl_GetVar (tcl_interp, "::geooptions.detail", 0)); double facets = atof (Tcl_GetVar (tcl_interp, "::geooptions.facets", 0)); if (atoi (Tcl_GetVar (tcl_interp, "::geooptions.drawcsg", 0))) geometry->CalcTriangleApproximation(box, detail, facets); #endif } else if (strcmp (&filename[strlen(filename)-4], "in2d") == 0) { geometry2d.Reset (new SplineGeometry2d()); geometry2d -> Load (filename); } else if ((strcmp (&filename[strlen(filename)-3], "stl") == 0) || (strcmp (&filename[strlen(filename)-3], "STL") == 0) || (strcmp (&filename[strlen(filename)-3], "Stl") == 0)) { stlgeometry = STLGeometry :: Load (infile); stlgeometry->edgesfound = 0; Mesh meshdummy; stlgeometry->Clear(); stlgeometry->BuildEdges(); stlgeometry->MakeAtlas(meshdummy); stlgeometry->CalcFaceNums(); stlgeometry->AddFaceEdges(); stlgeometry->LinkEdges(); } #ifdef OCCGEOMETRY else if ((strcmp (&filename[strlen(filename)-4], "iges") == 0) || (strcmp (&filename[strlen(filename)-3], "igs") == 0) || (strcmp (&filename[strlen(filename)-3], "IGS") == 0) || (strcmp (&filename[strlen(filename)-4], "IGES") == 0)) { PrintMessage (1, "Load IGES geometry file ", filename); occgeometry = LoadOCC_IGES (filename); } else if ((strcmp (&filename[strlen(filename)-4], "step") == 0) || (strcmp (&filename[strlen(filename)-3], "stp") == 0) || (strcmp (&filename[strlen(filename)-3], "STP") == 0) || (strcmp (&filename[strlen(filename)-4], "STEP") == 0)) { PrintMessage (1, "Load STEP geometry file ", filename); occgeometry = LoadOCC_STEP (filename); } #endif #ifdef ACIS else if ( strcmp (&filename[strlen(filename)-3], "sat") == 0 || ( strlen(filename) >= 7 && strcmp ( &filename[ strlen( filename)-7 ], "sat.tet" ) == 0 ) ) { PrintMessage (1, "Load ACIS geometry file ", filename); acisgeometry = LoadACIS_SAT (filename); } #endif else { //throw NgException("Unknown geometry extension"); cerr << "Error: Unknown geometry extension \"" << filename[strlen(filename)-3] << "\"" << endl; } } void Ng_LoadMeshFromStream ( istream & input ) { mesh.Reset (new Mesh()); mesh -> Load(input); if(input.good()) { string auxstring; input >> auxstring; if(auxstring == "csgsurfaces") { if (geometry) { geometry.Reset (new CSGeometry ("")); } if (stlgeometry) { delete stlgeometry; stlgeometry = NULL; } #ifdef OCCGEOMETRY if (occgeometry) { delete occgeometry; occgeometry = NULL; } #endif #ifdef ACIS if (acisgeometry) { delete acisgeometry; acisgeometry = NULL; } #endif geometry2d.Reset (0); geometry -> LoadSurfaces(input); } } } void Ng_LoadMesh (const char * filename) { if ( (strlen (filename) > 4) && strcmp (filename + (strlen (filename)-4), ".vol") != 0 ) { mesh.Reset (new Mesh()); ReadFile(*mesh,filename); //mesh->SetGlobalH (mparam.maxh); //mesh->CalcLocalH(); return; } ifstream infile(filename); Ng_LoadMeshFromStream(infile); } void Ng_LoadMeshFromString (const char * mesh_as_string) { istringstream instream(mesh_as_string); Ng_LoadMeshFromStream(instream); } int Ng_GetDimension () { return (mesh) ? mesh->GetDimension() : -1; } int Ng_GetNP () { return (mesh) ? mesh->GetNP() : 0; } int Ng_GetNV () { return (mesh) ? mesh->GetNV() : 0; } int Ng_GetNE () { if(!mesh) return 0; if (mesh->GetDimension() == 3) return mesh->GetNE(); else return mesh->GetNSE(); } int Ng_GetNSE () { if(!mesh) return 0; if (mesh->GetDimension() == 3) return mesh->GetNSE(); else return mesh->GetNSeg(); } void Ng_GetPoint (int pi, double * p) { if (pi < 1 || pi > mesh->GetNP()) { if (printmessage_importance>0) cout << "Ng_GetPoint: illegal point " << pi << endl; return; } const Point3d & hp = mesh->Point (pi); p[0] = hp.X(); p[1] = hp.Y(); if (mesh->GetDimension() == 3) p[2] = hp.Z(); } NG_ELEMENT_TYPE Ng_GetElement (int ei, int * epi, int * np) { if (mesh->GetDimension() == 3) { int i; const Element & el = mesh->VolumeElement (ei); for (i = 0; i < el.GetNP(); i++) epi[i] = el.PNum(i+1); if (np) *np = el.GetNP(); if (el.GetType() == PRISM) { // degenerated prism, (should be obsolete) const int map1[] = { 3, 2, 5, 6, 1 }; const int map2[] = { 1, 3, 6, 4, 2 }; const int map3[] = { 2, 1, 4, 5, 3 }; const int * map = NULL; int deg1 = 0, deg2 = 0, deg3 = 0; //int deg = 0; if (el.PNum(1) == el.PNum(4)) { map = map1; deg1 = 1; } if (el.PNum(2) == el.PNum(5)) { map = map2; deg2 = 1; } if (el.PNum(3) == el.PNum(6)) { map = map3; deg3 = 1; } switch (deg1+deg2+deg3) { { case 1: if (printmessage_importance>0) cout << "degenerated prism found, deg = 1" << endl; for (i = 0; i < 5; i++) epi[i] = el.PNum (map[i]); if (np) *np = 5; return NG_PYRAMID; break; } case 2: { if (printmessage_importance>0) cout << "degenerated prism found, deg = 2" << endl; if (!deg1) epi[3] = el.PNum(4); if (!deg2) epi[3] = el.PNum(5); if (!deg3) epi[3] = el.PNum(6); if (np) *np = 4; return NG_TET; break; } default: ; } } return NG_ELEMENT_TYPE (el.GetType()); } else { int i; const Element2d & el = mesh->SurfaceElement (ei); for (i = 0; i < el.GetNP(); i++) epi[i] = el.PNum(i+1); if (np) *np = el.GetNP(); return NG_ELEMENT_TYPE (el.GetType()); /* switch (el.GetNP()) { case 3: return NG_TRIG; case 4: return NG_QUAD; case 6: return NG_TRIG6; } */ } // should not occur return NG_TET; } NG_ELEMENT_TYPE Ng_GetElementType (int ei) { if (mesh->GetDimension() == 3) { return NG_ELEMENT_TYPE (mesh->VolumeElement (ei).GetType()); } else { const Element2d & el = mesh->SurfaceElement (ei); switch (el.GetNP()) { case 3: return NG_TRIG; case 4: return NG_QUAD; case 6: return NG_TRIG6; } } // should not occur return NG_TET; } int Ng_GetElementIndex (int ei) { if (mesh->GetDimension() == 3) return mesh->VolumeElement(ei).GetIndex(); else { int ind = mesh->SurfaceElement(ei).GetIndex(); ind = mesh->GetFaceDescriptor(ind).BCProperty(); return ind; } } void Ng_SetElementIndex(const int ei, const int index) { mesh->VolumeElement(ei).SetIndex(index); } char * Ng_GetElementMaterial (int ei) { static char empty[] = ""; if (mesh->GetDimension() == 3) { int ind = mesh->VolumeElement(ei).GetIndex(); // cout << "ind = " << ind << endl; const char * mat = mesh->GetMaterial (ind); if (mat) return const_cast (mat); else return empty; } // add astrid else { int ind = mesh->SurfaceElement(ei).GetIndex(); ind = mesh->GetFaceDescriptor(ind).BCProperty(); const char * mat = mesh->GetMaterial ( ind ); if (mat) return const_cast (mat); else return empty; } return 0; } char * Ng_GetDomainMaterial (int dom) { static char empty[] = ""; // astrid if ( 1 ) // mesh->GetDimension() == 3) { const char * mat = mesh->GetMaterial(dom); if (mat) return const_cast (mat); else return empty; } return 0; } int Ng_GetUserDataSize (char * id) { Array da; mesh->GetUserData (id, da); return da.Size(); } void Ng_GetUserData (char * id, double * data) { Array da; mesh->GetUserData (id, da); for (int i = 0; i < da.Size(); i++) data[i] = da[i]; } NG_ELEMENT_TYPE Ng_GetSurfaceElement (int ei, int * epi, int * np) { if (mesh->GetDimension() == 3) { const Element2d & el = mesh->SurfaceElement (ei); for (int i = 0; i < el.GetNP(); i++) epi[i] = el[i]; if (np) *np = el.GetNP(); return NG_ELEMENT_TYPE (el.GetType()); } else { const Segment & seg = mesh->LineSegment (ei); if (seg[2] < 0) { epi[0] = seg[0]; epi[1] = seg[1]; if (np) *np = 2; return NG_SEGM; } else { epi[0] = seg[0]; epi[1] = seg[1]; epi[2] = seg[2]; if (np) *np = 3; return NG_SEGM3; } } return NG_TRIG; } int Ng_GetSurfaceElementIndex (int ei) { if (mesh->GetDimension() == 3) return mesh->GetFaceDescriptor(mesh->SurfaceElement(ei).GetIndex()).BCProperty(); else return mesh->LineSegment(ei).si; } int Ng_GetSurfaceElementSurfaceNumber (int ei) { if (mesh->GetDimension() == 3) return mesh->GetFaceDescriptor(mesh->SurfaceElement(ei).GetIndex()).SurfNr(); else return mesh->LineSegment(ei).si; } int Ng_GetSurfaceElementFDNumber (int ei) { if (mesh->GetDimension() == 3) return mesh->SurfaceElement(ei).GetIndex(); else return -1; } char * Ng_GetSurfaceElementBCName (int ei) { if ( mesh->GetDimension() == 3 ) return const_cast(mesh->GetFaceDescriptor(mesh->SurfaceElement(ei).GetIndex()).GetBCName().c_str()); else return const_cast(mesh->LineSegment(ei).GetBCName().c_str()); } // Inefficient (but maybe safer) version: //void Ng_GetSurfaceElementBCName (int ei, char * name) //{ // if ( mesh->GetDimension() == 3 ) // strcpy(name,mesh->GetFaceDescriptor(mesh->SurfaceElement(ei).GetIndex()).GetBCName().c_str()); // else // strcpy(name,mesh->LineSegment(ei).GetBCName().c_str()); //} char * Ng_GetBCNumBCName (int bcnr) { return const_cast(mesh->GetBCName(bcnr).c_str()); } // Inefficient (but maybe safer) version: //void Ng_GetBCNumBCName (int bcnr, char * name) //{ // strcpy(name,mesh->GetBCName(bcnr).c_str()); //} void Ng_GetNormalVector (int sei, int locpi, double * nv) { nv[0] = 0; nv[1] = 0; nv[2] = 1; (*testout) << "Ng_GetNormalVector (sei = " << sei << ", locpi = " << locpi << ")" << endl; if (mesh->GetDimension() == 3) { Vec<3> n; Point<3> p; p = mesh->Point (mesh->SurfaceElement(sei).PNum(locpi)); int surfi = mesh->GetFaceDescriptor(mesh->SurfaceElement(sei).GetIndex()).SurfNr(); (*testout) << "surfi = " << surfi << endl; #ifdef OCCGEOMETRY if (occgeometry) { PointGeomInfo gi = mesh->SurfaceElement(sei).GeomInfoPi(locpi); occgeometry->GetSurface (surfi).GetNormalVector(p, gi, n); nv[0] = n(0); nv[1] = n(1); nv[2] = n(2); } else #endif if (geometry) { (*testout) << "geometry defined" << endl; n = geometry->GetSurface (surfi) -> GetNormalVector(p); (*testout) << "aus is" << endl; nv[0] = n(0); nv[1] = n(1); nv[2] = n(2); } } } void Ng_SetPointSearchStartElement(const int el) { mesh->SetPointSearchStartElement(el); } int Ng_FindElementOfPoint (double * p, double * lami, int build_searchtree, const int * const indices, const int numind) { Array * dummy(NULL); int ind = -1; if(indices != NULL) { dummy = new Array(numind); for(int i=0; iGetDimension() == 3) { Point3d p3d(p[0], p[1], p[2]); ind = mesh->GetElementOfPoint(p3d, lami, dummy, build_searchtree != 0); } else { double lam3[3]; Point3d p2d(p[0], p[1], 0); ind = mesh->GetElementOfPoint(p2d, lam3, dummy, build_searchtree != 0); if(mesh->SurfaceElement(ind).GetType()==QUAD) { lami[0] = lam3[0]; lami[1] = lam3[1]; } else { lami[0] = 1-lam3[0]-lam3[1]; lami[1] = lam3[0]; } } delete dummy; return ind; } int Ng_FindSurfaceElementOfPoint (double * p, double * lami, int build_searchtree, const int * const indices, const int numind) { Array * dummy(NULL); int ind = -1; if(indices != NULL) { dummy = new Array(numind); for(int i=0; iGetDimension() == 3) { Point3d p3d(p[0], p[1], p[2]); ind = mesh->GetSurfaceElementOfPoint(p3d, lami, dummy, build_searchtree != 0); } else { //throw NgException("FindSurfaceElementOfPoint for 2D meshes not yet implemented"); cerr << "FindSurfaceElementOfPoint for 2D meshes not yet implemented" << endl; } delete dummy; return ind; } int Ng_IsElementCurved (int ei) { if (mesh->GetDimension() == 2) return mesh->GetCurvedElements().IsSurfaceElementCurved (ei-1); else return mesh->GetCurvedElements().IsElementCurved (ei-1); } int Ng_IsSurfaceElementCurved (int sei) { if (mesh->GetDimension() == 2) return mesh->GetCurvedElements().IsSegmentCurved (sei-1); else return mesh->GetCurvedElements().IsSurfaceElementCurved (sei-1); } void Ng_GetElementTransformation (int ei, const double * xi, double * x, double * dxdxi) { if (mesh->GetDimension() == 2) { Point<2> xl(xi[0], xi[1]); Point<3> xg; Mat<3,2> dx; mesh->GetCurvedElements().CalcSurfaceTransformation (xl, ei-1, xg, dx); if (x) { for (int i = 0; i < 2; i++) x[i] = xg(i); } if (dxdxi) { for (int i=0; i<2; i++) { dxdxi[2*i] = dx(i,0); dxdxi[2*i+1] = dx(i,1); } } } else { Point<3> xl(xi[0], xi[1], xi[2]); Point<3> xg; Mat<3,3> dx; cout << "call calceltrafo" << endl; mesh->GetCurvedElements().CalcElementTransformation (xl, ei-1, xg, dx); cout << "xg = " << xg << endl << ", dx = " << dx << endl; // still 1-based arrays if (x) { for (int i = 0; i < 3; i++) x[i] = xg(i); } if (dxdxi) { for (int i=0; i<3; i++) { dxdxi[3*i] = dx(i,0); dxdxi[3*i+1] = dx(i,1); dxdxi[3*i+2] = dx(i,2); } } } } void Ng_GetBufferedElementTransformation (int ei, const double * xi, double * x, double * dxdxi, void * buffer, int buffervalid) { // buffer = 0; // buffervalid = 0; if (mesh->GetDimension() == 2) { return Ng_GetElementTransformation (ei, xi, x, dxdxi); } else { mesh->GetCurvedElements().CalcElementTransformation (reinterpret_cast &> (*xi), ei-1, reinterpret_cast &> (*x), reinterpret_cast &> (*dxdxi), buffer, (buffervalid != 0)); /* Point<3> xl(xi[0], xi[1], xi[2]); Point<3> xg; Mat<3,3> dx; // buffervalid = 0; mesh->GetCurvedElements().CalcElementTransformation (xl, ei-1, xg, dx, buffer, buffervalid); // still 1-based arrays if (x) { for (int i = 0; i < 3; i++) x[i] = xg(i); } if (dxdxi) { for (int i=0; i<3; i++) { dxdxi[3*i] = dx(i,0); dxdxi[3*i+1] = dx(i,1); dxdxi[3*i+2] = dx(i,2); } } */ } } void Ng_GetMultiElementTransformation (int ei, int n, const double * xi, size_t sxi, double * x, size_t sx, double * dxdxi, size_t sdxdxi) { if (mesh->GetDimension() == 2) mesh->GetCurvedElements().CalcMultiPointSurfaceTransformation<2> (ei-1, n, xi, sxi, x, sx, dxdxi, sdxdxi); else mesh->GetCurvedElements().CalcMultiPointElementTransformation (ei-1, n, xi, sxi, x, sx, dxdxi, sdxdxi); } void Ng_GetSurfaceElementTransformation (int sei, const double * xi, double * x, double * dxdxi) { if (mesh->GetDimension() == 2) { Point<3> xg; Vec<3> dx; mesh->GetCurvedElements().CalcSegmentTransformation (xi[0], sei-1, xg, dx); if (x) for (int i = 0; i < 2; i++) x[i] = xg(i); if (dxdxi) for (int i=0; i<2; i++) dxdxi[i] = dx(i); } else { Point<2> xl(xi[0], xi[1]); Point<3> xg; Mat<3,2> dx; mesh->GetCurvedElements().CalcSurfaceTransformation (xl, sei-1, xg, dx); for (int i=0; i<3; i++) { if (x) x[i] = xg(i); if (dxdxi) { dxdxi[2*i] = dx(i,0); dxdxi[2*i+1] = dx(i,1); } } } } int Ng_GetSegmentIndex (int ei) { const Segment & seg = mesh->LineSegment (ei); return seg.edgenr; } NG_ELEMENT_TYPE Ng_GetSegment (int ei, int * epi, int * np) { const Segment & seg = mesh->LineSegment (ei); epi[0] = seg[0]; epi[1] = seg[1]; if (seg[2] < 0) { if (np) *np = 2; return NG_SEGM; } else { epi[2] = seg[2]; if (np) *np = 3; return NG_SEGM3; } } void Ng_GetSurfaceElementNeighbouringDomains(const int selnr, int & in, int & out) { if ( mesh->GetDimension() == 3 ) { in = mesh->GetFaceDescriptor(mesh->SurfaceElement(selnr).GetIndex()).DomainIn(); out = mesh->GetFaceDescriptor(mesh->SurfaceElement(selnr).GetIndex()).DomainOut(); } else { in = mesh -> LineSegment(selnr) . domin; out = mesh -> LineSegment(selnr) . domout; } } #ifdef PARALLEL // Is Element ei an element of this processor ?? bool Ng_IsGhostEl (int ei) { if ( mesh->GetDimension() == 3 ) return mesh->VolumeElement(ei).IsGhost(); else return false; } void Ng_SetGhostEl(const int ei, const bool aisghost ) { if ( mesh -> GetDimension () == 3 ) mesh -> VolumeElement(ei).SetGhost (aisghost); } bool Ng_IsGhostSEl (int ei) { if ( mesh -> GetDimension () == 3 ) return mesh->SurfaceElement(ei).IsGhost(); else return false; } void Ng_SetGhostSEl(const int ei, const bool aisghost ) { if ( mesh -> GetDimension () == 3 ) mesh -> SurfaceElement(ei).SetGhost (aisghost); } bool Ng_IsGhostVert ( int pnum ) { return mesh -> Point ( pnum ).IsGhost() ; } bool Ng_IsGhostEdge ( int ednum ) { return mesh -> GetParallelTopology() . IsGhostEdge ( ednum ); } bool Ng_IsGhostFace ( int fanum ) { return mesh -> GetParallelTopology() . IsGhostFace ( fanum ); } // void Ng_SetGhostVert ( const int pnum, const bool aisghost ); // void Ng_SetGhostEdge ( const int ednum, const bool aisghost ); // void Ng_SetGhostFace ( const int fanum, const bool aisghost ); bool Ng_IsExchangeEl ( int elnum ) { return mesh -> GetParallelTopology() . IsExchangeElement ( elnum ); } bool Ng_IsExchangeSEl ( int selnum ) { return mesh -> GetParallelTopology() . IsExchangeSEl ( selnum ); } void Ng_UpdateOverlap() { mesh->UpdateOverlap(); } int Ng_Overlap () { return mesh->GetParallelTopology() . Overlap(); } #endif void Ng_SetRefinementFlag (int ei, int flag) { if (mesh->GetDimension() == 3) { mesh->VolumeElement(ei).SetRefinementFlag (flag != 0); mesh->VolumeElement(ei).SetStrongRefinementFlag (flag >= 10); } else { mesh->SurfaceElement(ei).SetRefinementFlag (flag != 0); mesh->SurfaceElement(ei).SetStrongRefinementFlag (flag >= 10); } } void Ng_SetSurfaceRefinementFlag (int ei, int flag) { if (mesh->GetDimension() == 3) { mesh->SurfaceElement(ei).SetRefinementFlag (flag != 0); mesh->SurfaceElement(ei).SetStrongRefinementFlag (flag >= 10); } } void Ng_Refine (NG_REFINEMENT_TYPE reftype) { NgLock meshlock (mesh->MajorMutex(), 1); BisectionOptions biopt; biopt.usemarkedelements = 1; biopt.refine_p = 0; biopt.refine_hp = 0; if (reftype == NG_REFINE_P) biopt.refine_p = 1; if (reftype == NG_REFINE_HP) biopt.refine_hp = 1; Refinement * ref; MeshOptimize2d * opt = NULL; if (geometry2d) ref = new Refinement2d(*geometry2d); else if (stlgeometry) ref = new RefinementSTLGeometry(*stlgeometry); #ifdef OCCGEOMETRY else if (occgeometry) ref = new OCCRefinementSurfaces (*occgeometry); #endif #ifdef ACIS else if (acisgeometry) { ref = new ACISRefinementSurfaces (*acisgeometry); opt = new ACISMeshOptimize2dSurfaces(*acisgeometry); ref->Set2dOptimizer(opt); } #endif else if (geometry && mesh->GetDimension() == 3) { ref = new RefinementSurfaces(*geometry); opt = new MeshOptimize2dSurfaces(*geometry); ref->Set2dOptimizer(opt); } else { ref = new Refinement(); } ref -> Bisect (*mesh, biopt); mesh -> UpdateTopology(); mesh -> GetCurvedElements().SetIsHighOrder (false); // mesh -> GetCurvedElements().BuildCurvedElements (ref, mparam.elementorder); delete ref; delete opt; } void Ng_SecondOrder () { if (stlgeometry) { RefinementSTLGeometry ref (*stlgeometry); ref.MakeSecondOrder (*mesh); } else if (geometry2d) { Refinement2d ref (*geometry2d); ref.MakeSecondOrder (*mesh); } else if (geometry && mesh->GetDimension() == 3) { RefinementSurfaces ref (*geometry); ref.MakeSecondOrder (*mesh); } else { if (printmessage_importance>0) cout << "no geom" << endl; Refinement ref; ref.MakeSecondOrder (*mesh); } mesh -> UpdateTopology(); } /* void Ng_HPRefinement (int levels) { Refinement * ref; if (stlgeometry) ref = new RefinementSTLGeometry (*stlgeometry); else if (geometry2d) ref = new Refinement2d (*geometry2d); else ref = new RefinementSurfaces (*geometry); HPRefinement (*mesh, ref, levels); } void Ng_HPRefinement (int levels, double parameter) { Refinement * ref; if (stlgeometry) ref = new RefinementSTLGeometry (*stlgeometry); else if (geometry2d) ref = new Refinement2d (*geometry2d); else ref = new RefinementSurfaces (*geometry); HPRefinement (*mesh, ref, levels, parameter); } */ void Ng_HPRefinement (int levels, double parameter, bool setorders, bool ref_level) { Refinement * ref; if (stlgeometry) ref = new RefinementSTLGeometry (*stlgeometry); else if (geometry2d) ref = new Refinement2d (*geometry2d); else ref = new RefinementSurfaces (*geometry); HPRefinement (*mesh, ref, levels, parameter, setorders, ref_level); } void Ng_HighOrder (int order, bool rational) { NgLock meshlock (mesh->MajorMutex(), true); Refinement * ref; if (stlgeometry) ref = new RefinementSTLGeometry (*stlgeometry); #ifdef OCCGEOMETRY else if (occgeometry) ref = new OCCRefinementSurfaces (*occgeometry); #endif #ifdef ACIS else if (acisgeometry) { ref = new ACISRefinementSurfaces (*acisgeometry); } #endif else if (geometry2d) ref = new Refinement2d (*geometry2d); else { ref = new RefinementSurfaces (*geometry); } // cout << "parameter 1: " << argv[1] << " (conversion to int = " << atoi(argv[1]) << ")" << endl; mesh -> GetCurvedElements().BuildCurvedElements (ref, order, rational); mesh -> SetNextMajorTimeStamp(); /* if(mesh) mesh -> GetCurvedElements().BuildCurvedElements (ref, order, rational); */ delete ref; } int Ng_ME_GetNVertices (NG_ELEMENT_TYPE et) { switch (et) { case NG_SEGM: case NG_SEGM3: return 2; case NG_TRIG: case NG_TRIG6: return 3; case NG_QUAD: return 4; case NG_TET: case NG_TET10: return 4; case NG_PYRAMID: return 5; case NG_PRISM: case NG_PRISM12: return 6; case NG_HEX: return 8; default: cerr << "Ng_ME_GetNVertices, illegal element type " << et << endl; } return 0; } int Ng_ME_GetNEdges (NG_ELEMENT_TYPE et) { switch (et) { case NG_SEGM: case NG_SEGM3: return 1; case NG_TRIG: case NG_TRIG6: return 3; case NG_QUAD: return 4; case NG_TET: case NG_TET10: return 6; case NG_PYRAMID: return 8; case NG_PRISM: case NG_PRISM12: return 9; case NG_HEX: return 12; default: cerr << "Ng_ME_GetNEdges, illegal element type " << et << endl; } return 0; } int Ng_ME_GetNFaces (NG_ELEMENT_TYPE et) { switch (et) { case NG_SEGM: case NG_SEGM3: return 0; case NG_TRIG: case NG_TRIG6: return 1; case NG_QUAD: case NG_QUAD6: return 1; case NG_TET: case NG_TET10: return 4; case NG_PYRAMID: return 5; case NG_PRISM: case NG_PRISM12: return 5; case NG_HEX: return 6; default: cerr << "Ng_ME_GetNVertices, illegal element type " << et << endl; } return 0; } const NG_POINT * Ng_ME_GetVertices (NG_ELEMENT_TYPE et) { static double segm_points [][3] = { { 1, 0, 0 }, { 0, 0, 0 } }; static double trig_points [][3] = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 0 } }; static double quad_points [][3] = { { 0, 0, 0 }, { 1, 0, 0 }, { 1, 1, 0 }, { 0, 1, 0 } }; static double tet_points [][3] = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 }, { 0, 0, 0 } }; static double pyramid_points [][3] = { { 0, 0, 0 }, { 1, 0, 0 }, { 1, 1, 0 }, { 0, 1, 0 }, { 0, 0, 1-1e-7 }, }; static double prism_points[][3] = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 0 }, { 1, 0, 1 }, { 0, 1, 1 }, { 0, 0, 1 } }; switch (et) { case NG_SEGM: case NG_SEGM3: return segm_points; case NG_TRIG: case NG_TRIG6: return trig_points; case NG_QUAD: case NG_QUAD6: return quad_points; case NG_TET: case NG_TET10: return tet_points; case NG_PYRAMID: return pyramid_points; case NG_PRISM: case NG_PRISM12: return prism_points; case NG_HEX: default: cerr << "Ng_ME_GetVertices, illegal element type " << et << endl; } return 0; } const NG_EDGE * Ng_ME_GetEdges (NG_ELEMENT_TYPE et) { static int segm_edges[1][2] = { { 1, 2 }}; static int trig_edges[3][2] = { { 3, 1 }, { 3, 2 }, { 1, 2 }}; static int quad_edges[4][2] = { { 1, 2 }, { 4, 3 }, { 1, 4 }, { 2, 3 }}; static int tet_edges[6][2] = { { 4, 1 }, { 4, 2 }, { 4, 3 }, { 1, 2 }, { 1, 3 }, { 2, 3 }}; static int prism_edges[9][2] = { { 3, 1 }, { 1, 2 }, { 3, 2 }, { 6, 4 }, { 4, 5 }, { 6, 5 }, { 3, 6 }, { 1, 4 }, { 2, 5 }}; static int pyramid_edges[8][2] = { { 1, 2 }, { 2, 3 }, { 1, 4 }, { 4, 3 }, { 1, 5 }, { 2, 5 }, { 3, 5 }, { 4, 5 }}; switch (et) { case NG_SEGM: case NG_SEGM3: return segm_edges; case NG_TRIG: case NG_TRIG6: return trig_edges; case NG_QUAD: case NG_QUAD6: return quad_edges; case NG_TET: case NG_TET10: return tet_edges; case NG_PYRAMID: return pyramid_edges; case NG_PRISM: case NG_PRISM12: return prism_edges; case NG_HEX: default: cerr << "Ng_ME_GetEdges, illegal element type " << et << endl; } return 0; } const NG_FACE * Ng_ME_GetFaces (NG_ELEMENT_TYPE et) { static int tet_faces[4][4] = { { 4, 2, 3, 0 }, { 4, 1, 3, 0 }, { 4, 1, 2, 0 }, { 1, 2, 3, 0 } }; static int prism_faces[5][4] = { { 1, 2, 3, 0 }, { 4, 5, 6, 0 }, { 3, 1, 4, 6 }, { 1, 2, 5, 4 }, { 2, 3, 6, 5 } }; static int pyramid_faces[5][4] = { { 1, 2, 5, 0 }, { 2, 3, 5, 0 }, { 3, 4, 5, 0 }, { 4, 1, 5, 0 }, { 1, 2, 3, 4 } }; static int trig_faces[1][4] = { { 1, 2, 3, 0 }, }; switch (et) { case NG_TET: case NG_TET10: return tet_faces; case NG_PRISM: case NG_PRISM12: return prism_faces; case NG_PYRAMID: return pyramid_faces; case NG_SEGM: case NG_SEGM3: case NG_TRIG: case NG_TRIG6: return trig_faces; case NG_QUAD: case NG_HEX: default: cerr << "Ng_ME_GetFaces, illegal element type " << et << endl; } return 0; } int Ng_GetNEdges() { return mesh->GetTopology().GetNEdges(); } int Ng_GetNFaces() { return mesh->GetTopology().GetNFaces(); } int Ng_GetElement_Edges (int elnr, int * edges, int * orient) { const MeshTopology & topology = mesh->GetTopology(); if (mesh->GetDimension() == 3) return topology.GetElementEdges (elnr, edges, orient); else return topology.GetSurfaceElementEdges (elnr, edges, orient); } int Ng_GetElement_Faces (int elnr, int * faces, int * orient) { const MeshTopology & topology = mesh->GetTopology(); if (mesh->GetDimension() == 3) return topology.GetElementFaces (elnr, faces, orient); else { faces[0] = elnr; if (orient) orient[0] = 0; return 1; } } int Ng_GetSurfaceElement_Edges (int elnr, int * edges, int * orient) { const MeshTopology & topology = mesh->GetTopology(); if (mesh->GetDimension() == 3) return topology.GetSurfaceElementEdges (elnr, edges, orient); else { if (orient) topology.GetSegmentEdge(elnr, edges[0], orient[0]); else edges[0] = topology.GetSegmentEdge(elnr); } return 1; /* int i, ned; const MeshTopology & topology = mesh->GetTopology(); Array ia; topology.GetSurfaceElementEdges (elnr, ia); ned = ia.Size(); for (i = 1; i <= ned; i++) edges[i-1] = ia.Get(i); if (orient) { topology.GetSurfaceElementEdgeOrientations (elnr, ia); for (i = 1; i <= ned; i++) orient[i-1] = ia.Get(i); } return ned; */ } int Ng_GetSurfaceElement_Face (int selnr, int * orient) { if (mesh->GetDimension() == 3) { const MeshTopology & topology = mesh->GetTopology(); if (orient) *orient = topology.GetSurfaceElementFaceOrientation (selnr); return topology.GetSurfaceElementFace (selnr); } return -1; } int Ng_GetFace_Vertices (int fnr, int * vert) { const MeshTopology & topology = mesh->GetTopology(); ArrayMem ia; topology.GetFaceVertices (fnr, ia); for (int i = 0; i < ia.Size(); i++) vert[i] = ia[i]; // cout << "face verts = " << ia << endl; return ia.Size(); } int Ng_GetFace_Edges (int fnr, int * edge) { const MeshTopology & topology = mesh->GetTopology(); ArrayMem ia; topology.GetFaceEdges (fnr, ia); for (int i = 0; i < ia.Size(); i++) edge[i] = ia[i]; return ia.Size(); } void Ng_GetEdge_Vertices (int ednr, int * vert) { const MeshTopology & topology = mesh->GetTopology(); topology.GetEdgeVertices (ednr, vert[0], vert[1]); } int Ng_GetNVertexElements (int vnr) { if (mesh->GetDimension() == 3) return mesh->GetTopology().GetVertexElements(vnr).Size(); else return mesh->GetTopology().GetVertexSurfaceElements(vnr).Size(); } void Ng_GetVertexElements (int vnr, int * els) { FlatArray ia(0,0); if (mesh->GetDimension() == 3) ia = mesh->GetTopology().GetVertexElements(vnr); else ia = mesh->GetTopology().GetVertexSurfaceElements(vnr); for (int i = 0; i < ia.Size(); i++) els[i] = ia[i]; } int Ng_GetElementOrder (int enr) { if (mesh->GetDimension() == 3) return mesh->VolumeElement(enr).GetOrder(); else return mesh->SurfaceElement(enr).GetOrder(); } void Ng_GetElementOrders (int enr, int * ox, int * oy, int * oz) { if (mesh->GetDimension() == 3) mesh->VolumeElement(enr).GetOrder(*ox, *oy, *oz); else mesh->SurfaceElement(enr).GetOrder(*ox, *oy, *oz); } void Ng_SetElementOrder (int enr, int order) { if (mesh->GetDimension() == 3) return mesh->VolumeElement(enr).SetOrder(order); else return mesh->SurfaceElement(enr).SetOrder(order); } void Ng_SetElementOrders (int enr, int ox, int oy, int oz) { if (mesh->GetDimension() == 3) mesh->VolumeElement(enr).SetOrder(ox, oy, oz); else mesh->SurfaceElement(enr).SetOrder(ox, oy); } int Ng_GetSurfaceElementOrder (int enr) { return mesh->SurfaceElement(enr).GetOrder(); } //HERBERT: falsche Anzahl von Argumenten //void Ng_GetSurfaceElementOrders (int enr, int * ox, int * oy, int * oz) void Ng_GetSurfaceElementOrders (int enr, int * ox, int * oy) { int d; mesh->SurfaceElement(enr).GetOrder(*ox, *oy, d); } void Ng_SetSurfaceElementOrder (int enr, int order) { return mesh->SurfaceElement(enr).SetOrder(order); } void Ng_SetSurfaceElementOrders (int enr, int ox, int oy) { mesh->SurfaceElement(enr).SetOrder(ox, oy); } int Ng_GetNLevels () { return (mesh) ? mesh->mglevels : 0; } void Ng_GetParentNodes (int ni, int * parents) { if (ni <= mesh->mlbetweennodes.Size()) { parents[0] = mesh->mlbetweennodes.Get(ni).I1(); parents[1] = mesh->mlbetweennodes.Get(ni).I2(); } else parents[0] = parents[1] = 0; } int Ng_GetParentElement (int ei) { if (mesh->GetDimension() == 3) { if (ei <= mesh->mlparentelement.Size()) return mesh->mlparentelement.Get(ei); } else { if (ei <= mesh->mlparentsurfaceelement.Size()) return mesh->mlparentsurfaceelement.Get(ei); } return 0; } int Ng_GetParentSElement (int ei) { if (mesh->GetDimension() == 3) { if (ei <= mesh->mlparentsurfaceelement.Size()) return mesh->mlparentsurfaceelement.Get(ei); } else { return 0; } return 0; } int Ng_GetClusterRepVertex (int pi) { return mesh->GetClusters().GetVertexRepresentant(pi); } int Ng_GetClusterRepEdge (int pi) { return mesh->GetClusters().GetEdgeRepresentant(pi); } int Ng_GetClusterRepFace (int pi) { return mesh->GetClusters().GetFaceRepresentant(pi); } int Ng_GetClusterRepElement (int pi) { return mesh->GetClusters().GetElementRepresentant(pi); } void Ng_InitSolutionData (Ng_SolutionData * soldata) { soldata -> name = NULL; soldata -> data = NULL; soldata -> components = 1; soldata -> dist = 1; soldata -> order = 1; soldata -> iscomplex = 0; soldata -> draw_surface = 1; soldata -> draw_volume = 1; soldata -> soltype = NG_SOLUTION_NODAL; soldata -> solclass = 0; } void Ng_SetSolutionData (Ng_SolutionData * soldata) { #ifdef OPENGL // vssolution.ClearSolutionData (); VisualSceneSolution::SolData * vss = new VisualSceneSolution::SolData; vss->name = new char[strlen (soldata->name)+1]; strcpy (vss->name, soldata->name); vss->data = soldata->data; vss->components = soldata->components; vss->dist = soldata->dist; vss->order = soldata->order; vss->iscomplex = bool(soldata->iscomplex); vss->draw_surface = soldata->draw_surface; vss->draw_volume = soldata->draw_volume; vss->soltype = VisualSceneSolution::SolType (soldata->soltype); vss->solclass = soldata->solclass; vssolution.AddSolutionData (vss); #endif } void Ng_ClearSolutionData () { #ifdef OPENGL vssolution.ClearSolutionData(); #endif } void Ng_Redraw () { #ifdef OPENGL extern bool nodisplay; // he: global in ngappinit.cpp if (!nodisplay) { vssolution.UpdateSolutionTimeStamp(); Render(); } #endif } void Ng_SetVisualizationParameter (const char * name, const char * value) { #ifdef OPENGL #ifndef NOTCL char buf[100]; sprintf (buf, "visoptions.%s", name); if (printmessage_importance>0) { cout << "name = " << name << ", value = " << value << endl; cout << "set tcl-variable " << buf << " to " << value << endl; } Tcl_SetVar (tcl_interp, buf, const_cast (value), 0); Tcl_Eval (tcl_interp, "Ng_Vis_Set parameters;"); #endif #endif } int firsttime = 1; int animcnt = 0; void PlayAnimFile(const char* name, int speed, int maxcnt) { //extern Mesh * mesh; /* if (mesh.Ptr()) mesh->DeleteMesh(); if (!mesh.Ptr()) mesh = new Mesh(); */ mesh.Reset (new Mesh()); int ne, np, i; char str[80]; char str2[80]; //int tend = 5000; // for (ti = 1; ti <= tend; ti++) //{ int rti = (animcnt%(maxcnt-1)) + 1; animcnt+=speed; sprintf(str2,"%05i.sol",rti); strcpy(str,"mbssol/"); strcat(str,name); strcat(str,str2); if (printmessage_importance>0) cout << "read file '" << str << "'" << endl; ifstream infile(str); infile >> ne; for (i = 1; i <= ne; i++) { int j; Element2d tri(TRIG); tri.SetIndex(1); //faceind for (j = 1; j <= 3; j++) infile >> tri.PNum(j); infile >> np; for (i = 1; i <= np; i++) { Point3d p; infile >> p.X() >> p.Y() >> p.Z(); if (firsttime) mesh->AddPoint (p); else mesh->Point(i) = Point<3> (p); } //firsttime = 0; Ng_Redraw(); } } int Ng_GetNPeriodicVertices (int idnr) { Array apairs; mesh->GetIdentifications().GetPairs (idnr, apairs); return apairs.Size(); } // pairs should be an integer array of 2*npairs void Ng_GetPeriodicVertices (int idnr, int * pairs) { Array apairs; mesh->GetIdentifications().GetPairs (idnr, apairs); for (int i = 0; i < apairs.Size(); i++) { pairs[2*i] = apairs[i].I1(); pairs[2*i+1] = apairs[i].I2(); } } int Ng_GetNPeriodicEdges (int idnr) { Array map; //const MeshTopology & top = mesh->GetTopology(); int nse = mesh->GetNSeg(); int cnt = 0; // for (int id = 1; id <= mesh->GetIdentifications().GetMaxNr(); id++) { mesh->GetIdentifications().GetMap(idnr, map); //(*testout) << "ident-map " << id << ":" << endl << map << endl; for (SegmentIndex si = 0; si < nse; si++) { PointIndex other1 = map[(*mesh)[si][0]]; PointIndex other2 = map[(*mesh)[si][1]]; // (*testout) << "seg = " << (*mesh)[si] << "; other = " // << other1 << "-" << other2 << endl; if (other1 && other2 && mesh->IsSegment (other1, other2)) { cnt++; } } } return cnt; } void Ng_GetPeriodicEdges (int idnr, int * pairs) { Array map; const MeshTopology & top = mesh->GetTopology(); int nse = mesh->GetNSeg(); int cnt = 0; // for (int id = 1; id <= mesh->GetIdentifications().GetMaxNr(); id++) { mesh->GetIdentifications().GetMap(idnr, map); //(*testout) << "map = " << map << endl; for (SegmentIndex si = 0; si < nse; si++) { PointIndex other1 = map[(*mesh)[si][0]]; PointIndex other2 = map[(*mesh)[si][1]]; if (other1 && other2 && mesh->IsSegment (other1, other2)) { SegmentIndex otherseg = mesh->SegmentNr (other1, other2); pairs[cnt++] = top.GetSegmentEdge (si+1); pairs[cnt++] = top.GetSegmentEdge (otherseg+1); } } } } void Ng_PushStatus (const char * str) { PushStatus (MyStr (str)); } void Ng_PopStatus () { PopStatus (); } void Ng_SetThreadPercentage (double percent) { SetThreadPercent (percent); } void Ng_GetStatus (char ** str, double & percent) { MyStr s; GetStatus(s,percent); *str = new char[s.Length()+1]; strcpy(*str,s.c_str()); } void Ng_SetTerminate(void) { multithread.terminate = 1; } void Ng_UnSetTerminate(void) { multithread.terminate = 0; } int Ng_ShouldTerminate(void) { return multithread.terminate; } void Ng_SetRunning(int flag) { multithread.running = flag; } int Ng_IsRunning() { return multithread.running; } ///// Added by Roman Stainko .... int Ng_GetVertex_Elements( int vnr, int* elems ) { const MeshTopology& topology = mesh->GetTopology(); ArrayMem indexArray; topology.GetVertexElements( vnr, indexArray ); for( int i=0; iGetTopology(); ArrayMem indexArray; topology.GetVertexSurfaceElements( vnr, indexArray ); for( int i=0; iGetTopology(); ArrayMem indexArray; topology.GetVertexElements( vnr, indexArray ); return indexArray.Size(); } ///// Added by Roman Stainko .... int Ng_GetVertex_NSurfaceElements( int vnr ) { const MeshTopology& topology = mesh->GetTopology(); ArrayMem indexArray; topology.GetVertexSurfaceElements( vnr, indexArray ); return indexArray.Size(); } #ifdef SOCKETS int Ng_SocketClientOpen( const int port, const char * host ) { try { if(host) clientsocket.Reset(new ClientSocket(port,host)); else clientsocket.Reset(new ClientSocket(port)); } catch( SocketException e) { cerr << e.Description() << endl; return 0; } return 1; } void Ng_SocketClientWrite( const char * write, char** reply) { string output = write; (*clientsocket) << output; string sreply; (*clientsocket) >> sreply; *reply = new char[sreply.size()+1]; strcpy(*reply,sreply.c_str()); } void Ng_SocketClientClose ( void ) { clientsocket.Reset(NULL); } void Ng_SocketClientGetServerHost ( const int number, char ** host ) { *host = new char[servers[number]->host.size()+1]; strcpy(*host,servers[number]->host.c_str()); } void Ng_SocketClientGetServerPort ( const int number, int * port ) { *port = servers[number]->port; } void Ng_SocketClientGetServerClientID ( const int number, int * id ) { *id = servers[number]->clientid; } #endif // SOCKETS #ifdef PARALLEL void Ng_SetElementPartition ( const int elnr, const int part ) { mesh->VolumeElement(elnr+1).SetPartition(part); } int Ng_GetElementPartition ( const int elnr ) { return mesh->VolumeElement(elnr+1).GetPartition(); } #endif void Ng_InitPointCurve(double red, double green, double blue) { mesh->InitPointCurve(red, green, blue); } void Ng_AddPointCurvePoint(const double * point) { Point3d pt; pt.X() = point[0]; pt.Y() = point[1]; pt.Z() = point[2]; mesh->AddPointCurvePoint(pt); } void Ng_SaveMesh ( const char * meshfile ) { mesh -> Save(string(meshfile)); } int Ng_Bisect_WithInfo ( const char * refinementfile, double ** qualityloss, int * qualityloss_size ) { BisectionOptions biopt; biopt.outfilename = NULL; // "ngfepp.vol"; biopt.femcode = "fepp"; biopt.refinementfilename = refinementfile; Refinement * ref; MeshOptimize2d * opt = NULL; if (stlgeometry) ref = new RefinementSTLGeometry(*stlgeometry); #ifdef OCCGEOMETRY else if (occgeometry) ref = new OCCRefinementSurfaces (*occgeometry); #endif #ifdef ACIS else if (acisgeometry) { ref = new ACISRefinementSurfaces(*acisgeometry); opt = new ACISMeshOptimize2dSurfaces(*acisgeometry); ref->Set2dOptimizer(opt); } #endif else { ref = new RefinementSurfaces(*geometry); opt = new MeshOptimize2dSurfaces(*geometry); ref->Set2dOptimizer(opt); } if(!mesh->LocalHFunctionGenerated()) mesh->CalcLocalH(); mesh->LocalHFunction().SetGrading (mparam.grading); Array * qualityloss_arr = NULL; if(qualityloss != NULL) qualityloss_arr = new Array; ref -> Bisect (*mesh, biopt, qualityloss_arr); int retval = 0; if(qualityloss != NULL) { *qualityloss = new double[qualityloss_arr->Size()+1]; for(int i = 0; iSize(); i++) (*qualityloss)[i+1] = (*qualityloss_arr)[i]; retval = qualityloss_arr->Size(); delete qualityloss_arr; } mesh -> UpdateTopology(); mesh -> GetCurvedElements().BuildCurvedElements (ref, mparam.elementorder); multithread.running = 0; delete ref; delete opt; return retval; } void Ng_Bisect ( const char * refinementfile ) { Ng_Bisect_WithInfo( refinementfile, NULL, NULL ); } /* number of nodes of type nt nt = 0 is Vertex nt = 1 is Edge nt = 2 is Face nt = 3 is Cell */ int Ng_GetNNodes (int nt) { switch (nt) { case 0: return mesh -> GetNV(); case 1: return mesh->GetTopology().GetNEdges(); case 2: return mesh->GetTopology().GetNFaces(); case 3: return mesh -> GetNE(); } return -1; } int Ng_GetClosureNodes (int nt, int nodenr, int nodeset, int * nodes) { switch (nt) { case 3: // The closure of a cell { int cnt = 0; if (nodeset & 1) // Vertices { const Element & el = (*mesh)[ElementIndex(nodenr)]; for (int i = 0; i < el.GetNP(); i++) { nodes[cnt++] = 0; nodes[cnt++] = el[i] - PointIndex::BASE; } } if (nodeset & 2) // Edges { int edges[12]; int ned; ned = mesh->GetTopology().GetElementEdges (nodenr+1, edges, 0); for (int i = 0; i < ned; i++) { nodes[cnt++] = 1; nodes[cnt++] = edges[i]-1; } } if (nodeset & 4) // Faces { int faces[12]; int nfa; nfa = mesh->GetTopology().GetElementFaces (nodenr+1, faces, 0); for (int i = 0; i < nfa; i++) { nodes[cnt++] = 2; nodes[cnt++] = faces[i]-1; } } if (nodeset & 8) // Cell { nodes[cnt++] = 3; nodes[cnt++] = nodenr; } return cnt/2; } default: { cerr << "GetClosureNodes not implemented for Nodetype " << nt << endl; } } return 0; } int Ng_GetNElements (int dim) { switch (dim) { case 0: return mesh -> GetNV(); case 1: return mesh -> GetNSeg(); case 2: return mesh -> GetNSE(); case 3: return mesh -> GetNE(); } return -1; } /* closure nodes of element nodeset is bit-coded, bit 0 includes Vertices, bit 1 edges, etc E.g., nodeset = 6 includes edge and face nodes nodes is pair of integers (nodetype, nodenr) return value is number of nodes */ int Ng_GetElementClosureNodes (int dim, int elementnr, int nodeset, int * nodes) { switch (dim) { case 3: // The closure of a volume element = CELL { return Ng_GetClosureNodes (3, elementnr, nodeset, nodes); } case 2: { int cnt = 0; if (nodeset & 1) // Vertices { const Element2d & el = (*mesh)[SurfaceElementIndex(elementnr)]; for (int i = 0; i < el.GetNP(); i++) { nodes[cnt++] = 0; nodes[cnt++] = el[i] - PointIndex::BASE; } } if (nodeset & 2) // Edges { int edges[12]; int ned; ned = mesh->GetTopology().GetSurfaceElementEdges (elementnr+1, edges, 0); for (int i = 0; i < ned; i++) { nodes[cnt++] = 1; nodes[cnt++] = edges[i]-1; } } if (nodeset & 4) // Faces { int face = mesh->GetTopology().GetSurfaceElementFace (elementnr+1); nodes[cnt++] = 2; nodes[cnt++] = face-1; } return cnt/2; } default: { cerr << "GetClosureNodes not implemented for Element of dimension " << dim << endl; } } return 0; } netgen-4.9.13/ng/parameters.tcl0000644000175000001440000000267411240003500013252 00000000000000proc setgranularity { gran } { # # puts "set granularity $gran" # if {$gran == 6} { return } set gran [expr $gran - 1] # global options.curvaturesafety set surfcurvlist { 1 1.5 2 3 5 } set options.curvaturesafety [lindex $surfcurvlist $gran] global options.segmentsperedge set spelist { 0.3 0.5 1 2 3 } set options.segmentsperedge [lindex $spelist $gran] global stloptions.resthsurfcurvfac set surfcurvfaclist { 0.25 0.5 1 1.5 3 } set stloptions.resthsurfcurvfac [lindex $surfcurvfaclist $gran] global stloptions.resthchartdistfac set chartdistfaclist { 0.8 1 1.5 2 5 } set stloptions.resthchartdistfac [lindex $chartdistfaclist $gran] global stloptions.resthlinelengthfac set linelengthfaclist { 0.2 0.35 0.5 1.5 3 } set stloptions.resthlinelengthfac [lindex $linelengthfaclist $gran] global stloptions.resthcloseedgefac set closeedgefaclist { 0.5 1 2 3.5 5 } set stloptions.resthcloseedgefac [lindex $closeedgefaclist $gran] global stloptions.resthedgeanglefac set edgeanglefaclist { 0.25 0.5 1 1.5 3 } set stloptions.resthedgeanglefac [lindex $edgeanglefaclist $gran] global stloptions.resthsurfmeshcurvfac set surfmeshcurvlist { 1 1.5 2 3 5 } set stloptions.resthsurfmeshcurvfac [lindex $surfmeshcurvlist $gran] global options.grading set gradinglist { 0.7 0.5 0.3 0.2 0.1 } set options.grading [lindex $gradinglist $gran] } netgen-4.9.13/ng/ngshell.tcl0000644000175000001440000001264111356013712012554 00000000000000## 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 # ---> global var in variables.tcl # 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 puts "register command $cmd" 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

contains edges resulting from face // intersections //======================================================================= void Partition_Loop2d::WiresToFaces(const BRepAlgo_Image& ) { Standard_Integer nbW = myNewWires.Extent() + myInternalWL.Extent(); if (nbW==0) return; BRepAlgo_FaceRestrictor FR; FR.Init (myFace,Standard_False); // FaceRestrictor is instable in rather simple cases // (ex. a single face of bellecoque.brep splited by 10 planes: // sometimes 1-2 faces are missing ). // So we use it as less as possible: no holes -> make faces by hands // are there holes in myFace ? Standard_Boolean hasOldHoles = Standard_False; TopoDS_Iterator itOldW (myFace); if ( itOldW.More()) { const TopoDS_Wire& FirstOldWire = TopoDS::Wire( itOldW.Value() ); itOldW.Next(); hasOldHoles = itOldW.More() || isHole( FirstOldWire, myFace); } if (myInternalWL.IsEmpty() && !hasOldHoles) { // each wire bounds one face BRep_Builder B; TopTools_ListIteratorOfListOfShape itNW (myNewWires); for (; itNW.More(); itNW.Next()) { TopoDS_Face NF = TopoDS::Face ( myFace.EmptyCopied() ); B.Add ( NF, itNW.Value() ); NF.Orientation( myFaceOri); myNewFaces.Append ( NF ); } return; } // FaceRestrictor can't classify wires build on all the same edges // and gives incorrect result in such cases (ex. a plane cut into 2 parts by cylinder) // We must make faces of equal wires separately. One of equal wires makes a // hole in a face and should come together with outer wires of face. // The other of a wires pair bounds a face that may have holes in turn. // Find equal wires among internal wires TopTools_DataMapOfShapeShape EqWM; // key is a hole part of a pair of equal wires findEqual (myInternalWL, EqWM, myFace); if (!EqWM.IsEmpty()) { // there are equal wires if (hasOldHoles) myInternalWL.Append( myNewWires ); // an old wire can be inside an equal wire // classify equal wire pairs BRepAlgo_AsDes OuterInner; classify (EqWM,OuterInner,myFace); // make face of most internal of equal wires and its inner wires while ( !EqWM.IsEmpty()) { TopTools_ListOfShape prevHolesL; // list of hole-part of previous most internal equal wires // find most internal wires among pairs (key - hole, value - outer part) TopTools_DataMapIteratorOfDataMapOfShapeShape it(EqWM); Standard_Integer nbEqW = EqWM.Extent(); // protection against infinite loop for ( ; it.More(); it.Next()) { TopoDS_Wire outerW = TopoDS::Wire ( it.Value() ); if ( OuterInner.HasDescendant( outerW ) && // has internal ! OuterInner.Descendant( outerW ).IsEmpty() ) continue; FR.Add( outerW ); // add internal wires that are inside of outerW TopTools_ListIteratorOfListOfShape itIW (myInternalWL); while ( itIW.More()) { TopoDS_Wire IW = TopoDS::Wire ( itIW.Value() ); if ( isInside (myFace, IW, outerW)) { FR.Add (IW); myInternalWL.Remove( itIW ); // == itIW.Next() !!! } else itIW.Next(); } // the hole-part of current pair of equal wires will be in the next new face prevHolesL.Append ( it.Key() ); } // Loop on map of equal pairs searching for innermost wires // make faces FR.Perform(); if (FR.IsDone()) { for (; FR.More(); FR.Next()) myNewFaces.Append(FR.Current()); } FR.Clear(); // add hole-parts to FaceRestrictor, // remove them from the EqWM, // remove found wires as internal of resting classified wires Standard_Boolean clearOuterInner = ( prevHolesL.Extent() < EqWM.Extent() ); TopTools_ListIteratorOfListOfShape itPrev (prevHolesL); for (; itPrev.More(); itPrev.Next()) { TopoDS_Wire& Hole = TopoDS::Wire ( itPrev.Value() ); FR.Add ( Hole ); if (clearOuterInner) { const TopoDS_Wire& outerW = TopoDS::Wire ( EqWM.Find( Hole ) ); // Loop on wires including outerW TopTools_ListIteratorOfListOfShape itO( OuterInner.Ascendant( outerW )); for (; itO.More(); itO.Next()) { TopTools_ListOfShape& innerL = OuterInner.ChangeDescendant( itO.Value() ); TopTools_ListIteratorOfListOfShape itI (innerL); // Loop on internal wires of current including wire for (; itI.More(); itI.Next()) if ( outerW.IsSame( itI.Value() )) { innerL.Remove( itI ); break; } } } EqWM.UnBind ( Hole ); } if (nbEqW == EqWM.Extent()) { // error: pb with wires classification #ifdef DEB MESSAGE("Partition_Loop2d::WiresToFaces(), pb with wires classification"); #endif break; } } // while (!EqWM.IsEmpty) } // if !EqWM.IsEmpty() myNewWires.Append ( myInternalWL ); TopTools_ListIteratorOfListOfShape itW (myNewWires); for (; itW.More(); itW.Next()) { TopoDS_Wire& W = TopoDS::Wire ( itW.Value() ); FR.Add(W); } FR.Perform(); for (; FR.IsDone() && FR.More(); FR.Next()) myNewFaces.Append(FR.Current()); TopTools_ListIteratorOfListOfShape itNF (myNewFaces); for (; itNF.More(); itNF.Next()) itNF.Value().Orientation( myFaceOri ); } #endif netgen-4.9.13/libsrc/occ/Partition_Loop.cxx0000644000175000001440000003247011244373410015522 00000000000000#ifdef OCCGEOMETRY // GEOM PARTITION : partition algorithm // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // // File : Partition_Loop.cxx // Author : Benedicte MARTIN // Module : GEOM // $Header: /cvs/netgen/netgen/libsrc/occ/Partition_Loop.cxx,v 1.6 2008/03/31 14:20:28 wabro Exp $ //using namespace std; #include #include #include "Partition_Loop.ixx" #include "utilities.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static char* name = new char[100]; static int nbe = 0; //======================================================================= //function : Partition_Loop //purpose : //======================================================================= Partition_Loop::Partition_Loop() { } //======================================================================= //function : Init //purpose : //======================================================================= void Partition_Loop::Init(const TopoDS_Face& F) { myConstEdges.Clear(); myNewWires .Clear(); myNewFaces .Clear(); myFace = F; } //======================================================================= //function : AddConstEdge //purpose : //======================================================================= void Partition_Loop::AddConstEdge (const TopoDS_Edge& E) { myConstEdges.Append(E); } //======================================================================= //function : FindDelta //purpose : //======================================================================= static Standard_Real FindDelta(TopTools_ListOfShape& LE, const TopoDS_Face& F) { Standard_Real dist, f, l; Standard_Real d = Precision::Infinite(); TopTools_ListIteratorOfListOfShape itl; for ( itl.Initialize(LE); itl.More(); itl.Next()) { const TopoDS_Edge& E = TopoDS::Edge(itl.Value()); Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface(E,F,f,l); gp_Pnt2d p = C->Value(f); gp_Pnt2d pp = C->Value(l); Standard_Real d1 = p.Distance(pp); if (d1 connected by the vertex in the list . // Is erased of the list. If is too in the list // with the same orientation, it's erased of the list //======================================================================= static Standard_Boolean SelectEdge(const TopoDS_Face& F, const TopoDS_Edge& CE, const TopoDS_Vertex& CV, TopoDS_Edge& NE, TopTools_ListOfShape& LE) { TopTools_ListIteratorOfListOfShape itl; NE.Nullify(); for ( itl.Initialize(LE); itl.More(); itl.Next()) { if (itl.Value().IsEqual(CE)) { LE.Remove(itl); break; } } if (LE.Extent() > 1) { //-------------------------------------------------------------- // Several possible edges. // - Test the edges differents of CE //-------------------------------------------------------------- Standard_Real cf, cl, f, l; TopoDS_Face FForward = F; Handle(Geom2d_Curve) Cc, C; FForward.Orientation(TopAbs_FORWARD); Cc = BRep_Tool::CurveOnSurface(CE,FForward,cf,cl); Standard_Real dist,distmin = 100*BRep_Tool::Tolerance(CV); Standard_Real uc,u; if (CE.Orientation () == TopAbs_FORWARD) uc = cl; else uc = cf; gp_Pnt2d P2,PV = Cc->Value(uc); Standard_Real delta = FindDelta(LE,FForward); for ( itl.Initialize(LE); itl.More(); itl.Next()) { const TopoDS_Edge& E = TopoDS::Edge(itl.Value()); if (!E.IsSame(CE)) { C = BRep_Tool::CurveOnSurface(E,FForward,f,l); if (E.Orientation () == TopAbs_FORWARD) u = f; else u = l; P2 = C->Value(u); dist = PV.Distance(P2); if (dist <= distmin){ distmin = dist; } } } Standard_Real anglemax = - PI; TopoDS_Edge SelectedEdge; for ( itl.Initialize(LE); itl.More(); itl.Next()) { const TopoDS_Edge& E = TopoDS::Edge(itl.Value()); if (!E.IsSame(CE)) { C = BRep_Tool::CurveOnSurface(E,FForward,f,l); if (E.Orientation () == TopAbs_FORWARD) u = f; else u = l; P2 = C->Value(u); dist = PV.Distance(P2); if (dist <= distmin + (1./3)*delta){ gp_Pnt2d PC, P; gp_Vec2d CTg1, CTg2, Tg1, Tg2; Cc->D2(uc, PC, CTg1, CTg2); C->D2(u, P, Tg1, Tg2); Standard_Real angle; if (CE.Orientation () == TopAbs_REVERSED && E.Orientation () == TopAbs_FORWARD) { angle = CTg1.Angle(Tg1.Reversed()); } else if (CE.Orientation () == TopAbs_FORWARD && E.Orientation () == TopAbs_REVERSED) { angle = (CTg1.Reversed()).Angle(Tg1); } else if (CE.Orientation () == TopAbs_REVERSED && E.Orientation () == TopAbs_REVERSED) { angle = CTg1.Angle(Tg1); } else if (CE.Orientation () == TopAbs_FORWARD && E.Orientation () == TopAbs_FORWARD) { angle = (CTg1.Reversed()).Angle(Tg1.Reversed()); } if (angle >= anglemax) { anglemax = angle ; SelectedEdge = E; } } } } for ( itl.Initialize(LE); itl.More(); itl.Next()) { const TopoDS_Edge& E = TopoDS::Edge(itl.Value()); if (E.IsEqual(SelectedEdge)) { NE = TopoDS::Edge(E); LE.Remove(itl); break; } } } else if (LE.Extent() == 1) { NE = TopoDS::Edge(LE.First()); LE.RemoveFirst(); } else { return Standard_False; } return Standard_True; } //======================================================================= //function : SamePnt2d //purpose : //======================================================================= static Standard_Boolean SamePnt2d(TopoDS_Vertex V, TopoDS_Edge& E1, TopoDS_Edge& E2, TopoDS_Face& F) { Standard_Real f1,f2,l1,l2; gp_Pnt2d P1,P2; TopoDS_Shape aLocalF = F.Oriented(TopAbs_FORWARD); TopoDS_Face FF = TopoDS::Face(aLocalF); Handle(Geom2d_Curve) C1 = BRep_Tool::CurveOnSurface(E1,FF,f1,l1); Handle(Geom2d_Curve) C2 = BRep_Tool::CurveOnSurface(E2,FF,f2,l2); if (E1.Orientation () == TopAbs_FORWARD) P1 = C1->Value(f1); else P1 = C1->Value(l1); if (E2.Orientation () == TopAbs_FORWARD) P2 = C2->Value(l2); else P2 = C2->Value(f2); Standard_Real Tol = 100*BRep_Tool::Tolerance(V); Standard_Real Dist = P1.Distance(P2); return Dist < Tol; } //======================================================================= //function : PurgeNewEdges //purpose : //======================================================================= static void PurgeNewEdges(TopTools_ListOfShape& ConstEdges, const TopTools_MapOfOrientedShape& UsedEdges) { TopTools_ListIteratorOfListOfShape it(ConstEdges); while ( it.More()) { const TopoDS_Shape& NE = it.Value(); if (!UsedEdges.Contains(NE)) { ConstEdges.Remove(it); } else { it.Next(); } } } //======================================================================= //function : StoreInMVE //purpose : //======================================================================= static void StoreInMVE (const TopoDS_Face& F, TopoDS_Edge& E, TopTools_DataMapOfShapeListOfShape& MVE ) { TopoDS_Vertex V1, V2; TopTools_ListOfShape Empty; TopExp::Vertices(E,V1,V2); if (!MVE.IsBound(V1)) { MVE.Bind(V1,Empty); } MVE(V1).Append(E); if (!MVE.IsBound(V2)) { MVE.Bind(V2,Empty); } MVE(V2).Append(E); } //======================================================================= //function : Perform //purpose : //======================================================================= void Partition_Loop::Perform() { TopTools_DataMapOfShapeListOfShape MVE; TopTools_DataMapIteratorOfDataMapOfShapeListOfShape Mapit, Mapit1; TopTools_ListIteratorOfListOfShape itl; TopoDS_Vertex V1,V2; //----------------------------------- // Construction map vertex => edges //----------------------------------- for (itl.Initialize(myConstEdges); itl.More(); itl.Next()) { TopoDS_Edge& E = TopoDS::Edge(itl.Value()); StoreInMVE(myFace,E,MVE); } //---------------------------------------------- // Construction of all the wires and of all the new faces. //---------------------------------------------- TopTools_MapOfOrientedShape UsedEdges; while (!MVE.IsEmpty()) { TopoDS_Vertex VF,CV; TopoDS_Edge CE,NE,EF; TopoDS_Wire NW; BRep_Builder B; Standard_Boolean End= Standard_False; B.MakeWire(NW); //-------------------------------- // EF first edge. //-------------------------------- Mapit.Initialize(MVE); EF = CE = TopoDS::Edge(Mapit.Value().First()); TopExp::Vertices(CE,V1,V2); //-------------------------------- // VF first vertex //-------------------------------- if (CE.Orientation() == TopAbs_FORWARD) { CV = VF = V1; } else { CV = VF = V2; } if (!MVE.IsBound(CV)) continue; for ( itl.Initialize(MVE(CV)); itl.More(); itl.Next()) { if (itl.Value().IsEqual(CE)) { MVE(CV).Remove(itl); break; } } int i = 0; while (!End) { //------------------------------- // Construction of a wire. //------------------------------- TopExp::Vertices(CE,V1,V2); if (!CV.IsSame(V1)) CV = V1; else CV = V2; B.Add (NW,CE); UsedEdges.Add(CE); //-------------- // stop test //-------------- if (!MVE.IsBound(CV) || MVE(CV).IsEmpty() || CV.IsSame(VF) ) { if (CV.IsSame(VF)) { if (MVE(CV).Extent() == 1 ) MVE.UnBind(CV); else { for ( itl.Initialize(MVE(CV)); itl.More(); itl.Next()) { if (itl.Value().IsEqual(CE)) { MVE(CV).Remove(itl); break; } } } } End=Standard_True; } //-------------- // select edge //-------------- else { Standard_Boolean find = SelectEdge(myFace,CE,CV,NE,MVE(CV)); if (find) { CE=NE; if (MVE(CV).IsEmpty()) MVE.UnBind(CV); if (CE.IsNull() ) { MESSAGE ( " CE is NULL !!! " ) End=Standard_True; } } else { MESSAGE ( " edge doesn't exist " ) End=Standard_True; } } } //----------------------------- // Test if the wire is closed //----------------------------- if (VF.IsSame(CV) && SamePnt2d(VF,EF,CE,myFace)) { } else{ MESSAGE ( "wire not closed" ) } myNewWires.Append (NW); } PurgeNewEdges(myConstEdges,UsedEdges); } //======================================================================= //function : NewWires //purpose : //======================================================================= const TopTools_ListOfShape& Partition_Loop::NewWires() const { return myNewWires; } //======================================================================= //function : NewFaces //purpose : //======================================================================= const TopTools_ListOfShape& Partition_Loop::NewFaces() const { return myNewFaces; } //======================================================================= //function : WiresToFaces //purpose : //======================================================================= void Partition_Loop::WiresToFaces() { if (!myNewWires.IsEmpty()) { BRepAlgo_FaceRestrictor FR; TopAbs_Orientation OriF = myFace.Orientation(); TopoDS_Shape aLocalS = myFace.Oriented(TopAbs_FORWARD); FR.Init (TopoDS::Face(aLocalS),Standard_False); TopTools_ListIteratorOfListOfShape it(myNewWires); for (; it.More(); it.Next()) { FR.Add(TopoDS::Wire(it.Value())); } FR.Perform(); if (FR.IsDone()) { for (; FR.More(); FR.Next()) { myNewFaces.Append(FR.Current().Oriented(OriF)); } } } } #endif netgen-4.9.13/libsrc/occ/occgeom.hpp0000644000175000001440000002700211323646263014163 00000000000000#ifndef FILE_OCCGEOM #define FILE_OCCGEOM /* *************************************************************************/ /* File: occgeom.hpp */ /* Author: Robert Gaisbauer */ /* Date: 26. May 03 */ /* *************************************************************************/ #ifdef OCCGEOMETRY #include #include "BRep_Tool.hxx" #include "Geom_Curve.hxx" #include "Geom2d_Curve.hxx" #include "Geom_Surface.hxx" #include "GeomAPI_ProjectPointOnSurf.hxx" #include "GeomAPI_ProjectPointOnCurve.hxx" #include "BRepTools.hxx" #include "TopExp.hxx" #include "BRepBuilderAPI_MakeVertex.hxx" #include "BRepBuilderAPI_MakeShell.hxx" #include "BRepBuilderAPI_MakeSolid.hxx" #include "BRepOffsetAPI_Sewing.hxx" #include "BRepLProp_SLProps.hxx" #include "BRepAdaptor_Surface.hxx" #include "Poly_Triangulation.hxx" #include "Poly_Array1OfTriangle.hxx" #include "TColgp_Array1OfPnt2d.hxx" #include "Poly_Triangle.hxx" #include "GProp_GProps.hxx" #include "BRepGProp.hxx" #include "Geom_Surface.hxx" #include "TopExp.hxx" #include "gp_Pnt.hxx" #include "TopoDS.hxx" #include "TopoDS_Solid.hxx" #include "TopExp_Explorer.hxx" #include "TopTools_ListIteratorOfListOfShape.hxx" #include "BRep_Tool.hxx" #include "Geom_Curve.hxx" #include "Geom2d_Curve.hxx" #include "Geom_Surface.hxx" #include "GeomAPI_ProjectPointOnSurf.hxx" #include "GeomAPI_ProjectPointOnCurve.hxx" #include "TopoDS_Wire.hxx" #include "BRepTools_WireExplorer.hxx" #include "BRepTools.hxx" #include "TopTools_IndexedMapOfShape.hxx" #include "TopExp.hxx" #include "BRepBuilderAPI_MakeVertex.hxx" #include "BRepBuilderAPI_MakeShell.hxx" #include "BRepBuilderAPI_MakeSolid.hxx" #include "BRepOffsetAPI_Sewing.hxx" #include "BRepLProp_CLProps.hxx" #include "BRepLProp_SLProps.hxx" #include "BRepAdaptor_Surface.hxx" #include "BRepAdaptor_Curve.hxx" #include "Poly_Triangulation.hxx" #include "Poly_Array1OfTriangle.hxx" #include "TColgp_Array1OfPnt2d.hxx" #include "Poly_Triangle.hxx" #include "GProp_GProps.hxx" #include "BRepGProp.hxx" #include "TopoDS_Shape.hxx" #include "TopoDS_Face.hxx" #include "IGESToBRep_Reader.hxx" #include "Interface_Static.hxx" #include "GeomAPI_ExtremaCurveCurve.hxx" #include "Standard_ErrorHandler.hxx" #include "Standard_Failure.hxx" #include "ShapeUpgrade_ShellSewing.hxx" #include "ShapeFix_Shape.hxx" #include "ShapeFix_Wireframe.hxx" #include "BRepMesh.hxx" #include "BRepMesh_IncrementalMesh.hxx" #include "BRepBndLib.hxx" #include "Bnd_Box.hxx" #include "ShapeAnalysis.hxx" #include "ShapeBuild_ReShape.hxx" // Philippose - 29/01/2009 // OpenCascade XDE Support // Include support for OpenCascade XDE Features #include "TDocStd_Document.hxx" #include "Quantity_Color.hxx" #include "XCAFApp_Application.hxx" #include "XCAFDoc_ShapeTool.hxx" #include "XCAFDoc_Color.hxx" #include "XCAFDoc_ColorTool.hxx" #include "XCAFDoc_ColorType.hxx" #include "XCAFDoc_LayerTool.hxx" #include "XCAFDoc_DimTolTool.hxx" #include "XCAFDoc_MaterialTool.hxx" #include "XCAFDoc_DocumentTool.hxx" #include "TDF_Label.hxx" #include "TDF_LabelSequence.hxx" #include "STEPCAFControl_Reader.hxx" #include "STEPCAFControl_Writer.hxx" #include "IGESCAFControl_Reader.hxx" #include "IGESCAFControl_Writer.hxx" #include "IGESControl_Reader.hxx" #include "STEPControl_Reader.hxx" #include "IGESControl_Writer.hxx" #include "STEPControl_Writer.hxx" #include "StlAPI_Writer.hxx" #include "STEPControl_StepModelType.hxx" namespace netgen { #include "occmeshsurf.hpp" #define PROJECTION_TOLERANCE 1e-10 #define ENTITYISVISIBLE 1 #define ENTITYISHIGHLIGHTED 2 #define ENTITYISDRAWABLE 4 #define OCCGEOMETRYVISUALIZATIONNOCHANGE 0 #define OCCGEOMETRYVISUALIZATIONFULLCHANGE 1 // Compute transformation matrices and redraw #define OCCGEOMETRYVISUALIZATIONHALFCHANGE 2 // Redraw class EntityVisualizationCode { int code; public: EntityVisualizationCode() { code = ENTITYISVISIBLE + !ENTITYISHIGHLIGHTED + ENTITYISDRAWABLE;} int IsVisible () { return code & ENTITYISVISIBLE;} int IsHighlighted () { return code & ENTITYISHIGHLIGHTED;} int IsDrawable () { return code & ENTITYISDRAWABLE;} void Show () { code |= ENTITYISVISIBLE;} void Hide () { code &= ~ENTITYISVISIBLE;} void Highlight () { code |= ENTITYISHIGHLIGHTED;} void Lowlight () { code &= ~ENTITYISHIGHLIGHTED;} void SetDrawable () { code |= ENTITYISDRAWABLE;} void SetNotDrawable () { code &= ~ENTITYISDRAWABLE;} }; class Line { public: Point<3> p0, p1; double Dist (Line l); double Length (); }; inline double Det3 (double a00, double a01, double a02, double a10, double a11, double a12, double a20, double a21, double a22) { return a00*a11*a22 + a01*a12*a20 + a10*a21*a02 - a20*a11*a02 - a10*a01*a22 - a21*a12*a00; } class OCCGeometry : public NetgenGeometry { Point<3> center; public: TopoDS_Shape shape; TopTools_IndexedMapOfShape fmap, emap, vmap, somap, shmap, wmap; Array fsingular, esingular, vsingular; Box<3> boundingbox; // Philippose - 29/01/2009 // OpenCascade XDE Support // XCAF Handle to make the face colours available to the rest of // the system Handle_XCAFDoc_ColorTool face_colours; int changed; Array facemeshstatus; // Philippose - 15/01/2009 // Maximum mesh size for a given face // (Used to explicitly define mesh size limits on individual faces) Array face_maxh; // Philippose - 14/01/2010 // Boolean array to detect whether a face has been explicitly modified // by the user or not Array face_maxh_modified; // Philippose - 15/01/2009 // Indicates which faces have been selected by the user in geometry mode // (Currently handles only selection of one face at a time, but an array would // help to extend this to multiple faces) Array face_sel_status; Array fvispar, evispar, vvispar; double tolerance; bool fixsmalledges; bool fixspotstripfaces; bool sewfaces; bool makesolids; bool splitpartitions; OCCGeometry() { somap.Clear(); shmap.Clear(); fmap.Clear(); wmap.Clear(); emap.Clear(); vmap.Clear(); } void BuildFMap(); Box<3> GetBoundingBox() { return boundingbox;} int NrSolids() { return somap.Extent();} // Philippose - 17/01/2009 // Total number of faces in the geometry int NrFaces() { return fmap.Extent();} void SetCenter() { center = boundingbox.Center();} Point<3> Center() { return center;} void Project (int surfi, Point<3> & p) const; bool FastProject (int surfi, Point<3> & ap, double& u, double& v) const; OCCSurface GetSurface (int surfi) { cout << "OCCGeometry::GetSurface using PLANESPACE" << endl; return OCCSurface (TopoDS::Face(fmap(surfi)), PLANESPACE); } void CalcBoundingBox (); void BuildVisualizationMesh (double deflection); void RecursiveTopologyTree (const TopoDS_Shape & sh, stringstream & str, TopAbs_ShapeEnum l, bool free, const char * lname); void GetTopologyTree (stringstream & str); void PrintNrShapes (); void CheckIrregularEntities (stringstream & str); void SewFaces(); void MakeSolid(); void HealGeometry(); // Philippose - 15/01/2009 // Sets the maximum mesh size for a given face // (Note: Local mesh size limited by the global max mesh size) void SetFaceMaxH(int facenr, double faceh) { if((facenr> 0) && (facenr <= fmap.Extent())) { face_maxh[facenr-1] = min(mparam.maxh,faceh); // Philippose - 14/01/2010 // If the face maxh is greater than or equal to the // current global maximum, then identify the face as // not explicitly controlled by the user any more if(faceh >= mparam.maxh) { face_maxh_modified[facenr-1] = 0; } else { face_maxh_modified[facenr-1] = 1; } } } // Philippose - 15/01/2009 // Returns the local mesh size of a given face double GetFaceMaxH(int facenr) { if((facenr> 0) && (facenr <= fmap.Extent())) { return face_maxh[facenr-1]; } else { return 0.0; } } // Philippose - 14/01/2010 // Returns the flag whether the given face // has a mesh size controlled by the user or not bool GetFaceMaxhModified(int facenr) { return face_maxh_modified[facenr-1]; } // Philippose - 17/01/2009 // Returns the index of the currently selected face int SelectedFace() { int i; for(i = 1; i <= fmap.Extent(); i++) { if(face_sel_status[i-1]) { return i; } } return 0; } // Philippose - 17/01/2009 // Sets the currently selected face void SetSelectedFace(int facenr) { face_sel_status = 0; if((facenr >= 1) && (facenr <= fmap.Extent())) { face_sel_status[facenr-1] = 1; } } void LowLightAll() { for (int i = 1; i <= fmap.Extent(); i++) fvispar[i-1].Lowlight(); for (int i = 1; i <= emap.Extent(); i++) evispar[i-1].Lowlight(); for (int i = 1; i <= vmap.Extent(); i++) vvispar[i-1].Lowlight(); } void GetUnmeshedFaceInfo (stringstream & str); void GetNotDrawableFaces (stringstream & str); bool ErrorInSurfaceMeshing (); void WriteOCC_STL(char * filename); virtual int GenerateMesh (Mesh*& mesh, int perfstepsstart, int perfstepsend, char* optstring); virtual const Refinement & GetRefinement () const; }; class OCCParameters { public: /// Factor for meshing close edges double resthcloseedgefac; /// Enable / Disable detection of close edges int resthcloseedgeenable; /*! Default Constructor for the OpenCascade Mesh generation parameter set */ OCCParameters(); /*! Dump all the OpenCascade specific meshing parameters to console */ void Print (ostream & ost) const; }; void PrintContents (OCCGeometry * geom); OCCGeometry * LoadOCC_IGES (const char * filename); OCCGeometry * LoadOCC_STEP (const char * filename); OCCGeometry * LoadOCC_BREP (const char * filename); extern OCCParameters occparam; // Philippose - 31.09.2009 // External access to the mesh generation functions within the OCC // subsystem (Not sure if this is the best way to implement this....!!) extern int OCCGenerateMesh (OCCGeometry & occgeometry, Mesh*& mesh, int perfstepsstart, int perfstepsend, char* optstring); extern void OCCSetLocalMeshSize(OCCGeometry & geom, Mesh & mesh); extern void OCCMeshSurface (OCCGeometry & geom, Mesh & mesh, int perfstepsend); extern void OCCFindEdges (OCCGeometry & geom, Mesh & mesh); } #endif #endif netgen-4.9.13/libsrc/occ/Partition_Loop2d.hxx0000644000175000001440000000360611244373410015754 00000000000000// GEOM PARTITION : partition algorithm // // Copyright (C) 2003 CEA/DEN, EDF R&D // // // // File : Partition_Loop2d.hxx // Module : GEOM #ifndef _Partition_Loop2d_HeaderFile #define _Partition_Loop2d_HeaderFile #ifndef _TopoDS_Face_HeaderFile #include #endif #ifndef _TopAbs_Orientation_HeaderFile #include #endif #ifndef _TopTools_ListOfShape_HeaderFile #include #endif #ifndef _TopTools_MapOfShape_HeaderFile #include #endif class TopoDS_Face; class TopoDS_Edge; class TopTools_ListOfShape; class BRepAlgo_Image; #ifndef _Standard_HeaderFile #include #endif #ifndef _Standard_Macro_HeaderFile #include #endif class Partition_Loop2d { public: void* operator new(size_t,void* anAddress) { return anAddress; } void* operator new(size_t size) { return Standard::Allocate(size); } void operator delete(void *anAddress) { if (anAddress) Standard::Free((Standard_Address&)anAddress); } // Methods PUBLIC // Partition_Loop2d(); void Init(const TopoDS_Face& F) ; void AddConstEdge(const TopoDS_Edge& E) ; void AddSectionEdge(const TopoDS_Edge& E) ; void Perform() ; const TopTools_ListOfShape& NewWires() const; void WiresToFaces(const BRepAlgo_Image& EdgeImage) ; const TopTools_ListOfShape& NewFaces() const; protected: // Methods PROTECTED // // Fields PROTECTED // private: // Methods PRIVATE // // Fields PRIVATE // TopoDS_Face myFace; TopAbs_Orientation myFaceOri; TopTools_ListOfShape myConstEdges; TopTools_ListOfShape myNewWires; TopTools_ListOfShape myNewFaces; TopTools_ListOfShape myInternalWL; TopTools_MapOfShape mySectionEdges; }; // other Inline functions and methods (like "C++: function call" methods) // #endif netgen-4.9.13/libsrc/occ/occgeom.cpp0000644000175000001440000013543711344202045014157 00000000000000 #ifdef OCCGEOMETRY #include #include #include "ShapeAnalysis_ShapeTolerance.hxx" #include "ShapeAnalysis_ShapeContents.hxx" #include "ShapeAnalysis_CheckSmallFace.hxx" #include "ShapeAnalysis_DataMapOfShapeListOfReal.hxx" #include "ShapeAnalysis_Surface.hxx" #include "BRepAlgoAPI_Fuse.hxx" #include "BRepCheck_Analyzer.hxx" #include "BRepLib.hxx" #include "ShapeBuild_ReShape.hxx" #include "ShapeFix.hxx" #include "ShapeFix_FixSmallFace.hxx" #include "Partition_Spliter.hxx" namespace netgen { void OCCGeometry :: PrintNrShapes () { TopExp_Explorer e; int count = 0; for (e.Init(shape, TopAbs_COMPSOLID); e.More(); e.Next()) count++; cout << "CompSolids: " << count << endl; cout << "Solids : " << somap.Extent() << endl; cout << "Shells : " << shmap.Extent() << endl; cout << "Faces : " << fmap.Extent() << endl; cout << "Edges : " << emap.Extent() << endl; cout << "Vertices : " << vmap.Extent() << endl; } void PrintContents (OCCGeometry * geom) { ShapeAnalysis_ShapeContents cont; cont.Clear(); cont.Perform(geom->shape); (*testout) << "OCC CONTENTS" << endl; (*testout) << "============" << endl; (*testout) << "SOLIDS : " << cont.NbSolids() << endl; (*testout) << "SHELLS : " << cont.NbShells() << endl; (*testout) << "FACES : " << cont.NbFaces() << endl; (*testout) << "WIRES : " << cont.NbWires() << endl; (*testout) << "EDGES : " << cont.NbEdges() << endl; (*testout) << "VERTICES : " << cont.NbVertices() << endl; TopExp_Explorer e; int count = 0; for (e.Init(geom->shape, TopAbs_COMPOUND); e.More(); e.Next()) count++; (*testout) << "Compounds: " << count << endl; count = 0; for (e.Init(geom->shape, TopAbs_COMPSOLID); e.More(); e.Next()) count++; (*testout) << "CompSolids: " << count << endl; (*testout) << endl; cout << "Highest entry in topology hierarchy: " << endl; if (count) cout << count << " composite solid(s)" << endl; else if (geom->somap.Extent()) cout << geom->somap.Extent() << " solid(s)" << endl; else if (geom->shmap.Extent()) cout << geom->shmap.Extent() << " shells(s)" << endl; else if (geom->fmap.Extent()) cout << geom->fmap.Extent() << " face(s)" << endl; else if (geom->wmap.Extent()) cout << geom->wmap.Extent() << " wire(s)" << endl; else if (geom->emap.Extent()) cout << geom->emap.Extent() << " edge(s)" << endl; else if (geom->vmap.Extent()) cout << geom->vmap.Extent() << " vertices(s)" << endl; else cout << "no entities" << endl; } void OCCGeometry :: HealGeometry () { int nrc = 0, nrcs = 0, nrso = somap.Extent(), nrsh = shmap.Extent(), nrf = fmap.Extent(), nrw = wmap.Extent(), nre = emap.Extent(), nrv = vmap.Extent(); TopExp_Explorer exp0; TopExp_Explorer exp1; for (exp0.Init(shape, TopAbs_COMPOUND); exp0.More(); exp0.Next()) nrc++; for (exp0.Init(shape, TopAbs_COMPSOLID); exp0.More(); exp0.Next()) nrcs++; double surfacecont = 0; { Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; rebuild->Apply(shape); for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next()) { TopoDS_Edge edge = TopoDS::Edge(exp1.Current()); if ( BRep_Tool::Degenerated(edge) ) rebuild->Remove(edge, false); } shape = rebuild->Apply(shape); } BuildFMap(); for (exp0.Init (shape, TopAbs_FACE); exp0.More(); exp0.Next()) { TopoDS_Face face = TopoDS::Face(exp0.Current()); GProp_GProps system; BRepGProp::SurfaceProperties(face, system); surfacecont += system.Mass(); } cout << "Starting geometry healing procedure (tolerance: " << tolerance << ")" << endl << "-----------------------------------" << endl; { cout << endl << "- repairing faces" << endl; Handle(ShapeFix_Face) sff; Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; rebuild->Apply(shape); for (exp0.Init (shape, TopAbs_FACE); exp0.More(); exp0.Next()) { // Variable to hold the colour (if there exists one) of // the current face being processed Quantity_Color face_colour; TopoDS_Face face = TopoDS::Face (exp0.Current()); if(face_colours.IsNull() || (!(face_colours->GetColor(face,XCAFDoc_ColorSurf,face_colour)))) { // Set the default face colour to green (Netgen Standard) // if no colour has been defined for the face face_colour = Quantity_Color(0.0,1.0,0.0,Quantity_TOC_RGB); } sff = new ShapeFix_Face (face); sff->FixAddNaturalBoundMode() = Standard_True; sff->FixSmallAreaWireMode() = Standard_True; sff->Perform(); if(sff->Status(ShapeExtend_DONE1) || sff->Status(ShapeExtend_DONE2) || sff->Status(ShapeExtend_DONE3) || sff->Status(ShapeExtend_DONE4) || sff->Status(ShapeExtend_DONE5)) { cout << "repaired face " << fmap.FindIndex(face) << " "; if(sff->Status(ShapeExtend_DONE1)) cout << "(some wires are fixed)" <Status(ShapeExtend_DONE2)) cout << "(orientation of wires fixed)" <Status(ShapeExtend_DONE3)) cout << "(missing seam added)" <Status(ShapeExtend_DONE4)) cout << "(small area wire removed)" <Status(ShapeExtend_DONE5)) cout << "(natural bounds added)" <Face(); rebuild->Replace(face, newface, Standard_False); } // Set the original colour of the face to the newly created // face (after the healing process) face = TopoDS::Face (exp0.Current()); face_colours->SetColor(face,face_colour,XCAFDoc_ColorSurf); } shape = rebuild->Apply(shape); } { Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; rebuild->Apply(shape); for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next()) { TopoDS_Edge edge = TopoDS::Edge(exp1.Current()); if ( BRep_Tool::Degenerated(edge) ) rebuild->Remove(edge, false); } shape = rebuild->Apply(shape); } if (fixsmalledges) { cout << endl << "- fixing small edges" << endl; Handle(ShapeFix_Wire) sfw; Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; rebuild->Apply(shape); for (exp0.Init (shape, TopAbs_FACE); exp0.More(); exp0.Next()) { TopoDS_Face face = TopoDS::Face(exp0.Current()); for (exp1.Init (face, TopAbs_WIRE); exp1.More(); exp1.Next()) { TopoDS_Wire oldwire = TopoDS::Wire(exp1.Current()); sfw = new ShapeFix_Wire (oldwire, face ,tolerance); sfw->ModifyTopologyMode() = Standard_True; sfw->ClosedWireMode() = Standard_True; bool replace = false; replace = sfw->FixReorder() || replace; replace = sfw->FixConnected() || replace; if (sfw->FixSmall (Standard_False, tolerance) && ! (sfw->StatusSmall(ShapeExtend_FAIL1) || sfw->StatusSmall(ShapeExtend_FAIL2) || sfw->StatusSmall(ShapeExtend_FAIL3))) { cout << "Fixed small edge in wire " << wmap.FindIndex (oldwire) << endl; replace = true; } else if (sfw->StatusSmall(ShapeExtend_FAIL1)) cerr << "Failed to fix small edge in wire " << wmap.FindIndex (oldwire) << ", edge cannot be checked (no 3d curve and no pcurve)" << endl; else if (sfw->StatusSmall(ShapeExtend_FAIL2)) cerr << "Failed to fix small edge in wire " << wmap.FindIndex (oldwire) << ", edge is null-length and has different vertives at begin and end, and lockvtx is True or ModifiyTopologyMode is False" << endl; else if (sfw->StatusSmall(ShapeExtend_FAIL3)) cerr << "Failed to fix small edge in wire " << wmap.FindIndex (oldwire) << ", CheckConnected has failed" << endl; replace = sfw->FixEdgeCurves() || replace; replace = sfw->FixDegenerated() || replace; replace = sfw->FixSelfIntersection() || replace; replace = sfw->FixLacking(Standard_True) || replace; if(replace) { TopoDS_Wire newwire = sfw->Wire(); rebuild->Replace(oldwire, newwire, Standard_False); } //delete sfw; sfw = NULL; } } shape = rebuild->Apply(shape); { BuildFMap(); Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; rebuild->Apply(shape); for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next()) { TopoDS_Edge edge = TopoDS::Edge(exp1.Current()); if (vmap.FindIndex(TopExp::FirstVertex (edge)) == vmap.FindIndex(TopExp::LastVertex (edge))) { GProp_GProps system; BRepGProp::LinearProperties(edge, system); if (system.Mass() < tolerance) { cout << "removing degenerated edge " << emap.FindIndex(edge) << " from vertex " << vmap.FindIndex(TopExp::FirstVertex (edge)) << " to vertex " << vmap.FindIndex(TopExp::LastVertex (edge)) << endl; rebuild->Remove(edge, false); } } } shape = rebuild->Apply(shape); //delete rebuild; rebuild = NULL; } { Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; rebuild->Apply(shape); for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next()) { TopoDS_Edge edge = TopoDS::Edge(exp1.Current()); if ( BRep_Tool::Degenerated(edge) ) rebuild->Remove(edge, false); } shape = rebuild->Apply(shape); } Handle(ShapeFix_Wireframe) sfwf = new ShapeFix_Wireframe; sfwf->SetPrecision(tolerance); sfwf->Load (shape); sfwf->ModeDropSmallEdges() = Standard_True; sfwf->SetPrecision(boundingbox.Diam()); if (sfwf->FixWireGaps()) { cout << endl << "- fixing wire gaps" << endl; if (sfwf->StatusWireGaps(ShapeExtend_OK)) cout << "no gaps found" << endl; if (sfwf->StatusWireGaps(ShapeExtend_DONE1)) cout << "some 2D gaps fixed" << endl; if (sfwf->StatusWireGaps(ShapeExtend_DONE2)) cout << "some 3D gaps fixed" << endl; if (sfwf->StatusWireGaps(ShapeExtend_FAIL1)) cout << "failed to fix some 2D gaps" << endl; if (sfwf->StatusWireGaps(ShapeExtend_FAIL2)) cout << "failed to fix some 3D gaps" << endl; } sfwf->SetPrecision(tolerance); { for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next()) { TopoDS_Edge edge = TopoDS::Edge(exp1.Current()); if ( BRep_Tool::Degenerated(edge) ) cout << "degenerated edge at position 4" << endl; } } if (sfwf->FixSmallEdges()) { cout << endl << "- fixing wire frames" << endl; if (sfwf->StatusSmallEdges(ShapeExtend_OK)) cout << "no small edges found" << endl; if (sfwf->StatusSmallEdges(ShapeExtend_DONE1)) cout << "some small edges fixed" << endl; if (sfwf->StatusSmallEdges(ShapeExtend_FAIL1)) cout << "failed to fix some small edges" << endl; } shape = sfwf->Shape(); //delete sfwf; sfwf = NULL; //delete rebuild; rebuild = NULL; } { for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next()) { TopoDS_Edge edge = TopoDS::Edge(exp1.Current()); if ( BRep_Tool::Degenerated(edge) ) cout << "degenerated edge at position 5" << endl; } } if (fixspotstripfaces) { cout << endl << "- fixing spot and strip faces" << endl; Handle(ShapeFix_FixSmallFace) sffsm = new ShapeFix_FixSmallFace(); sffsm -> Init (shape); sffsm -> SetPrecision (tolerance); sffsm -> Perform(); shape = sffsm -> FixShape(); //delete sffsm; sffsm = NULL; } { for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next()) { TopoDS_Edge edge = TopoDS::Edge(exp1.Current()); if ( BRep_Tool::Degenerated(edge) ) cout << "degenerated edge at position 6" << endl; } } if (sewfaces) { cout << endl << "- sewing faces" << endl; BRepOffsetAPI_Sewing sewedObj(tolerance); for (exp0.Init (shape, TopAbs_FACE); exp0.More(); exp0.Next()) { TopoDS_Face face = TopoDS::Face (exp0.Current()); sewedObj.Add (face); } sewedObj.Perform(); if (!sewedObj.SewedShape().IsNull()) shape = sewedObj.SewedShape(); else cout << " not possible"; } { Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; rebuild->Apply(shape); for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next()) { TopoDS_Edge edge = TopoDS::Edge(exp1.Current()); if ( BRep_Tool::Degenerated(edge) ) rebuild->Remove(edge, false); } shape = rebuild->Apply(shape); } if (makesolids) { cout << endl << "- making solids" << endl; BRepBuilderAPI_MakeSolid ms; int count = 0; for (exp0.Init(shape, TopAbs_SHELL); exp0.More(); exp0.Next()) { count++; ms.Add (TopoDS::Shell(exp0.Current())); } if (!count) { cout << " not possible (no shells)" << endl; } else { BRepCheck_Analyzer ba(ms); if (ba.IsValid ()) { Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape; sfs->Init (ms); sfs->SetPrecision(tolerance); sfs->SetMaxTolerance(tolerance); sfs->Perform(); shape = sfs->Shape(); for (exp0.Init(shape, TopAbs_SOLID); exp0.More(); exp0.Next()) { TopoDS_Solid solid = TopoDS::Solid(exp0.Current()); TopoDS_Solid newsolid = solid; BRepLib::OrientClosedSolid (newsolid); Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; // rebuild->Apply(shape); rebuild->Replace(solid, newsolid, Standard_False); TopoDS_Shape newshape = rebuild->Apply(shape, TopAbs_COMPSOLID);//, 1); // TopoDS_Shape newshape = rebuild->Apply(shape); shape = newshape; } //delete sfs; sfs = NULL; } else cout << " not possible" << endl; } } if (splitpartitions) { cout << "- running SALOME partition splitter" << endl; TopExp_Explorer e2; Partition_Spliter ps; int count = 0; for (e2.Init (shape, TopAbs_SOLID); e2.More(); e2.Next()) { count++; ps.AddShape (e2.Current()); } ps.Compute(); shape = ps.Shape(); cout << " before: " << count << " solids" << endl; count = 0; for (e2.Init (shape, TopAbs_SOLID); e2.More(); e2.Next()) count++; cout << " after : " << count << " solids" << endl; } BuildFMap(); { for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next()) { TopoDS_Edge edge = TopoDS::Edge(exp1.Current()); if ( BRep_Tool::Degenerated(edge) ) cout << "degenerated edge at position 8" << endl; } } double newsurfacecont = 0; for (exp0.Init (shape, TopAbs_FACE); exp0.More(); exp0.Next()) { TopoDS_Face face = TopoDS::Face(exp0.Current()); GProp_GProps system; BRepGProp::SurfaceProperties(face, system); newsurfacecont += system.Mass(); } int nnrc = 0, nnrcs = 0, nnrso = somap.Extent(), nnrsh = shmap.Extent(), nnrf = fmap.Extent(), nnrw = wmap.Extent(), nnre = emap.Extent(), nnrv = vmap.Extent(); for (exp0.Init(shape, TopAbs_COMPOUND); exp0.More(); exp0.Next()) nnrc++; for (exp0.Init(shape, TopAbs_COMPSOLID); exp0.More(); exp0.Next()) nnrcs++; cout << "-----------------------------------" << endl; cout << "Compounds : " << nnrc << " (" << nrc << ")" << endl; cout << "Composite solids: " << nnrcs << " (" << nrcs << ")" << endl; cout << "Solids : " << nnrso << " (" << nrso << ")" << endl; cout << "Shells : " << nnrsh << " (" << nrsh << ")" << endl; cout << "Wires : " << nnrw << " (" << nrw << ")" << endl; cout << "Faces : " << nnrf << " (" << nrf << ")" << endl; cout << "Edges : " << nnre << " (" << nre << ")" << endl; cout << "Vertices : " << nnrv << " (" << nrv << ")" << endl; cout << endl; cout << "Totol surface area : " << newsurfacecont << " (" << surfacecont << ")" << endl; cout << endl; } void OCCGeometry :: BuildFMap() { somap.Clear(); shmap.Clear(); fmap.Clear(); wmap.Clear(); emap.Clear(); vmap.Clear(); TopExp_Explorer exp0, exp1, exp2, exp3, exp4, exp5; for (exp0.Init(shape, TopAbs_COMPOUND); exp0.More(); exp0.Next()) { TopoDS_Compound compound = TopoDS::Compound (exp0.Current()); (*testout) << "compound" << endl; int i = 0; for (exp1.Init(compound, TopAbs_SHELL); exp1.More(); exp1.Next()) { (*testout) << "shell " << ++i << endl; } } for (exp0.Init(shape, TopAbs_SOLID); exp0.More(); exp0.Next()) { TopoDS_Solid solid = TopoDS::Solid (exp0.Current()); if (somap.FindIndex(solid) < 1) { somap.Add (solid); for (exp1.Init(solid, TopAbs_SHELL); exp1.More(); exp1.Next()) { TopoDS_Shell shell = TopoDS::Shell (exp1.Current()); if (shmap.FindIndex(shell) < 1) { shmap.Add (shell); for (exp2.Init(shell, TopAbs_FACE); exp2.More(); exp2.Next()) { TopoDS_Face face = TopoDS::Face(exp2.Current()); if (fmap.FindIndex(face) < 1) { fmap.Add (face); (*testout) << "face " << fmap.FindIndex(face) << " "; (*testout) << ((face.Orientation() == TopAbs_REVERSED) ? "-" : "+") << ", "; (*testout) << ((exp2.Current().Orientation() == TopAbs_REVERSED) ? "-" : "+") << endl; for (exp3.Init(exp2.Current(), TopAbs_WIRE); exp3.More(); exp3.Next()) { TopoDS_Wire wire = TopoDS::Wire (exp3.Current()); if (wmap.FindIndex(wire) < 1) { wmap.Add (wire); for (exp4.Init(exp3.Current(), TopAbs_EDGE); exp4.More(); exp4.Next()) { TopoDS_Edge edge = TopoDS::Edge(exp4.Current()); if (emap.FindIndex(edge) < 1) { emap.Add (edge); for (exp5.Init(exp4.Current(), TopAbs_VERTEX); exp5.More(); exp5.Next()) { TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current()); if (vmap.FindIndex(vertex) < 1) vmap.Add (vertex); } } } } } } } } } } } // Free Shells for (exp1.Init(shape, TopAbs_SHELL, TopAbs_SOLID); exp1.More(); exp1.Next()) { TopoDS_Shell shell = TopoDS::Shell(exp1.Current()); if (shmap.FindIndex(shell) < 1) { shmap.Add (shell); (*testout) << "shell " << shmap.FindIndex(shell) << " "; (*testout) << ((shell.Orientation() == TopAbs_REVERSED) ? "-" : "+") << ", "; (*testout) << ((exp1.Current().Orientation() == TopAbs_REVERSED) ? "-" : "+") << endl; for (exp2.Init(shell, TopAbs_FACE); exp2.More(); exp2.Next()) { TopoDS_Face face = TopoDS::Face(exp2.Current()); if (fmap.FindIndex(face) < 1) { fmap.Add (face); for (exp3.Init(face, TopAbs_WIRE); exp3.More(); exp3.Next()) { TopoDS_Wire wire = TopoDS::Wire (exp3.Current()); if (wmap.FindIndex(wire) < 1) { wmap.Add (wire); for (exp4.Init(wire, TopAbs_EDGE); exp4.More(); exp4.Next()) { TopoDS_Edge edge = TopoDS::Edge(exp4.Current()); if (emap.FindIndex(edge) < 1) { emap.Add (edge); for (exp5.Init(edge, TopAbs_VERTEX); exp5.More(); exp5.Next()) { TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current()); if (vmap.FindIndex(vertex) < 1) vmap.Add (vertex); } } } } } } } } } // Free Faces for (exp2.Init(shape, TopAbs_FACE, TopAbs_SHELL); exp2.More(); exp2.Next()) { TopoDS_Face face = TopoDS::Face(exp2.Current()); if (fmap.FindIndex(face) < 1) { fmap.Add (face); for (exp3.Init(exp2.Current(), TopAbs_WIRE); exp3.More(); exp3.Next()) { TopoDS_Wire wire = TopoDS::Wire (exp3.Current()); if (wmap.FindIndex(wire) < 1) { wmap.Add (wire); for (exp4.Init(exp3.Current(), TopAbs_EDGE); exp4.More(); exp4.Next()) { TopoDS_Edge edge = TopoDS::Edge(exp4.Current()); if (emap.FindIndex(edge) < 1) { emap.Add (edge); for (exp5.Init(exp4.Current(), TopAbs_VERTEX); exp5.More(); exp5.Next()) { TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current()); if (vmap.FindIndex(vertex) < 1) vmap.Add (vertex); } } } } } } } // Free Wires for (exp3.Init(shape, TopAbs_WIRE, TopAbs_FACE); exp3.More(); exp3.Next()) { TopoDS_Wire wire = TopoDS::Wire (exp3.Current()); if (wmap.FindIndex(wire) < 1) { wmap.Add (wire); for (exp4.Init(exp3.Current(), TopAbs_EDGE); exp4.More(); exp4.Next()) { TopoDS_Edge edge = TopoDS::Edge(exp4.Current()); if (emap.FindIndex(edge) < 1) { emap.Add (edge); for (exp5.Init(exp4.Current(), TopAbs_VERTEX); exp5.More(); exp5.Next()) { TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current()); if (vmap.FindIndex(vertex) < 1) vmap.Add (vertex); } } } } } // Free Edges for (exp4.Init(shape, TopAbs_EDGE, TopAbs_WIRE); exp4.More(); exp4.Next()) { TopoDS_Edge edge = TopoDS::Edge(exp4.Current()); if (emap.FindIndex(edge) < 1) { emap.Add (edge); for (exp5.Init(exp4.Current(), TopAbs_VERTEX); exp5.More(); exp5.Next()) { TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current()); if (vmap.FindIndex(vertex) < 1) vmap.Add (vertex); } } } // Free Vertices for (exp5.Init(shape, TopAbs_VERTEX, TopAbs_EDGE); exp5.More(); exp5.Next()) { TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current()); if (vmap.FindIndex(vertex) < 1) vmap.Add (vertex); } facemeshstatus.DeleteAll(); facemeshstatus.SetSize (fmap.Extent()); facemeshstatus = 0; // Philippose - 15/01/2009 face_maxh.DeleteAll(); face_maxh.SetSize (fmap.Extent()); face_maxh = mparam.maxh; // Philippose - 15/01/2010 face_maxh_modified.DeleteAll(); face_maxh_modified.SetSize(fmap.Extent()); face_maxh_modified = 0; // Philippose - 17/01/2009 face_sel_status.DeleteAll(); face_sel_status.SetSize (fmap.Extent()); face_sel_status = 0; fvispar.SetSize (fmap.Extent()); evispar.SetSize (emap.Extent()); vvispar.SetSize (vmap.Extent()); fsingular.SetSize (fmap.Extent()); esingular.SetSize (emap.Extent()); vsingular.SetSize (vmap.Extent()); fsingular = esingular = vsingular = false; } void OCCGeometry :: SewFaces () { (*testout) << "Trying to sew faces ..." << endl; cout << "Trying to sew faces ..." << flush; BRepOffsetAPI_Sewing sewedObj(1); for (int i = 1; i <= fmap.Extent(); i++) { TopoDS_Face face = TopoDS::Face (fmap(i)); sewedObj.Add (face); } sewedObj.Perform(); if (!sewedObj.SewedShape().IsNull()) { shape = sewedObj.SewedShape(); cout << " done" << endl; } else cout << " not possible"; } void OCCGeometry :: MakeSolid () { TopExp_Explorer exp0; (*testout) << "Trying to build solids ..." << endl; cout << "Trying to build solids ..." << flush; BRepBuilderAPI_MakeSolid ms; int count = 0; for (exp0.Init(shape, TopAbs_SHELL); exp0.More(); exp0.Next()) { count++; ms.Add (TopoDS::Shell(exp0.Current())); } if (!count) { cout << " not possible (no shells)" << endl; return; } BRepCheck_Analyzer ba(ms); if (ba.IsValid ()) { Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape; sfs->Init (ms); sfs->SetPrecision(1e-5); sfs->SetMaxTolerance(1e-5); sfs->Perform(); shape = sfs->Shape(); for (exp0.Init(shape, TopAbs_SOLID); exp0.More(); exp0.Next()) { TopoDS_Solid solid = TopoDS::Solid(exp0.Current()); TopoDS_Solid newsolid = solid; BRepLib::OrientClosedSolid (newsolid); Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; rebuild->Replace(solid, newsolid, Standard_False); TopoDS_Shape newshape = rebuild->Apply(shape, TopAbs_SHAPE, 1); shape = newshape; } cout << " done" << endl; } else cout << " not possible" << endl; } void OCCGeometry :: BuildVisualizationMesh (double deflection) { cout << "Preparing visualization (deflection = " << deflection << ") ... " << flush; BRepTools::Clean (shape); // BRepMesh_IncrementalMesh:: BRepMesh_IncrementalMesh (shape, deflection, true); cout << "done" << endl; } void OCCGeometry :: CalcBoundingBox () { Bnd_Box bb; BRepBndLib::Add (shape, bb); double x1,y1,z1,x2,y2,z2; bb.Get (x1,y1,z1,x2,y2,z2); Point<3> p1 = Point<3> (x1,y1,z1); Point<3> p2 = Point<3> (x2,y2,z2); (*testout) << "Bounding Box = [" << p1 << " - " << p2 << "]" << endl; boundingbox = Box<3> (p1,p2); SetCenter(); } void OCCGeometry :: Project (int surfi, Point<3> & p) const { static int cnt = 0; if (++cnt % 1000 == 0) cout << "Project cnt = " << cnt << endl; gp_Pnt pnt(p(0), p(1), p(2)); double u,v; Handle( Geom_Surface ) thesurf = BRep_Tool::Surface(TopoDS::Face(fmap(surfi))); Handle( ShapeAnalysis_Surface ) su = new ShapeAnalysis_Surface( thesurf ); gp_Pnt2d suval = su->ValueOfUV ( pnt, BRep_Tool::Tolerance( TopoDS::Face(fmap(surfi)) ) ); suval.Coord( u, v); pnt = thesurf->Value( u, v ); p = Point<3> (pnt.X(), pnt.Y(), pnt.Z()); } bool OCCGeometry :: FastProject (int surfi, Point<3> & ap, double& u, double& v) const { gp_Pnt p(ap(0), ap(1), ap(2)); Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi))); gp_Pnt x = surface->Value (u,v); if (p.SquareDistance(x) <= sqr(PROJECTION_TOLERANCE)) return true; gp_Vec du, dv; surface->D1(u,v,x,du,dv); int count = 0; gp_Pnt xold; gp_Vec n; double det, lambda, mu; do { count++; n = du^dv; det = Det3 (n.X(), du.X(), dv.X(), n.Y(), du.Y(), dv.Y(), n.Z(), du.Z(), dv.Z()); if (det < 1e-15) return false; lambda = Det3 (n.X(), p.X()-x.X(), dv.X(), n.Y(), p.Y()-x.Y(), dv.Y(), n.Z(), p.Z()-x.Z(), dv.Z())/det; mu = Det3 (n.X(), du.X(), p.X()-x.X(), n.Y(), du.Y(), p.Y()-x.Y(), n.Z(), du.Z(), p.Z()-x.Z())/det; u += lambda; v += mu; xold = x; surface->D1(u,v,x,du,dv); } while (xold.SquareDistance(x) > sqr(PROJECTION_TOLERANCE) && count < 50); // (*testout) << "FastProject count: " << count << endl; if (count == 50) return false; ap = Point<3> (x.X(), x.Y(), x.Z()); return true; } void OCCGeometry :: WriteOCC_STL(char * filename) { cout << "writing stl..."; cout.flush(); StlAPI_Writer writer; writer.RelativeMode() = Standard_False; writer.SetDeflection(0.02); writer.Write(shape,filename); cout << "done" << endl; } // Philippose - 23/02/2009 /* Special IGES File load function including the ability to extract individual surface colours via the extended OpenCascade XDE and XCAF Feature set. */ OCCGeometry *LoadOCC_IGES(const char *filename) { OCCGeometry *occgeo; occgeo = new OCCGeometry; // Initiate a dummy XCAF Application to handle the IGES XCAF Document static Handle_XCAFApp_Application dummy_app = XCAFApp_Application::GetApplication(); // Create an XCAF Document to contain the IGES file itself Handle_TDocStd_Document iges_doc; // Check if a IGES File is already open under this handle, if so, close it to prevent // Segmentation Faults when trying to create a new document if(dummy_app->NbDocuments() > 0) { dummy_app->GetDocument(1,iges_doc); dummy_app->Close(iges_doc); } dummy_app->NewDocument ("IGES-XCAF",iges_doc); IGESCAFControl_Reader reader; Standard_Integer stat = reader.ReadFile((char*)filename); if(stat != IFSelect_RetDone) { delete occgeo; return NULL; } // Enable transfer of colours reader.SetColorMode(Standard_True); reader.Transfer(iges_doc); // Read in the shape(s) and the colours present in the IGES File Handle_XCAFDoc_ShapeTool iges_shape_contents = XCAFDoc_DocumentTool::ShapeTool(iges_doc->Main()); Handle_XCAFDoc_ColorTool iges_colour_contents = XCAFDoc_DocumentTool::ColorTool(iges_doc->Main()); TDF_LabelSequence iges_shapes; iges_shape_contents->GetShapes(iges_shapes); // List out the available colours in the IGES File as Colour Names TDF_LabelSequence all_colours; iges_colour_contents->GetColors(all_colours); PrintMessage(1,"Number of colours in IGES File: ",all_colours.Length()); for(int i = 1; i <= all_colours.Length(); i++) { Quantity_Color col; stringstream col_rgb; iges_colour_contents->GetColor(all_colours.Value(i),col); col_rgb << " : (" << col.Red() << "," << col.Green() << "," << col.Blue() << ")"; PrintMessage(1, "Colour [", i, "] = ",col.StringName(col.Name()),col_rgb.str()); } // For the IGES Reader, all the shapes can be exported as one compund shape // using the "OneShape" member occgeo->shape = reader.OneShape(); occgeo->face_colours = iges_colour_contents; occgeo->changed = 1; occgeo->BuildFMap(); occgeo->CalcBoundingBox(); PrintContents (occgeo); return occgeo; } // Philippose - 29/01/2009 /* Special STEP File load function including the ability to extract individual surface colours via the extended OpenCascade XDE and XCAF Feature set. */ OCCGeometry * LoadOCC_STEP (const char * filename) { OCCGeometry * occgeo; occgeo = new OCCGeometry; // Initiate a dummy XCAF Application to handle the STEP XCAF Document static Handle_XCAFApp_Application dummy_app = XCAFApp_Application::GetApplication(); // Create an XCAF Document to contain the STEP file itself Handle_TDocStd_Document step_doc; // Check if a STEP File is already open under this handle, if so, close it to prevent // Segmentation Faults when trying to create a new document if(dummy_app->NbDocuments() > 0) { dummy_app->GetDocument(1,step_doc); dummy_app->Close(step_doc); } dummy_app->NewDocument ("STEP-XCAF",step_doc); STEPCAFControl_Reader reader; // Enable transfer of colours reader.SetColorMode(Standard_True); Standard_Integer stat = reader.ReadFile((char*)filename); if(stat != IFSelect_RetDone) { delete occgeo; return NULL; } reader.Transfer(step_doc); // Read in the shape(s) and the colours present in the STEP File Handle_XCAFDoc_ShapeTool step_shape_contents = XCAFDoc_DocumentTool::ShapeTool(step_doc->Main()); Handle_XCAFDoc_ColorTool step_colour_contents = XCAFDoc_DocumentTool::ColorTool(step_doc->Main()); TDF_LabelSequence step_shapes; step_shape_contents->GetShapes(step_shapes); // List out the available colours in the STEP File as Colour Names TDF_LabelSequence all_colours; step_colour_contents->GetColors(all_colours); PrintMessage(1,"Number of colours in STEP File: ",all_colours.Length()); for(int i = 1; i <= all_colours.Length(); i++) { Quantity_Color col; stringstream col_rgb; step_colour_contents->GetColor(all_colours.Value(i),col); col_rgb << " : (" << col.Red() << "," << col.Green() << "," << col.Blue() << ")"; PrintMessage(1, "Colour [", i, "] = ",col.StringName(col.Name()),col_rgb.str()); } // For the STEP File Reader in OCC, the 1st Shape contains the entire // compound geometry as one shape occgeo->shape = step_shape_contents->GetShape(step_shapes.Value(1)); occgeo->face_colours = step_colour_contents; occgeo->changed = 1; occgeo->BuildFMap(); occgeo->CalcBoundingBox(); PrintContents (occgeo); return occgeo; } OCCGeometry *LoadOCC_BREP (const char *filename) { OCCGeometry * occgeo; occgeo = new OCCGeometry; BRep_Builder aBuilder; Standard_Boolean result = BRepTools::Read(occgeo->shape, const_cast (filename),aBuilder); if(!result) { delete occgeo; return NULL; } // Philippose - 23/02/2009 // Fixed a bug in the OpenCascade XDE Colour handling when // opening BREP Files, since BREP Files have no colour data. // Hence, the face_colours Handle needs to be created as a NULL handle. occgeo->face_colours = Handle_XCAFDoc_ColorTool(); occgeo->face_colours.Nullify(); occgeo->changed = 1; occgeo->BuildFMap(); occgeo->CalcBoundingBox(); PrintContents (occgeo); return occgeo; } const char * shapesname[] = {" ", "CompSolids", "Solids", "Shells", "Faces", "Wires", "Edges", "Vertices"}; const char * shapename[] = {" ", "CompSolid", "Solid", "Shell", "Face", "Wire", "Edge", "Vertex"}; const char * orientationstring[] = {"+", "-"}; void OCCGeometry :: RecursiveTopologyTree (const TopoDS_Shape & sh, stringstream & str, TopAbs_ShapeEnum l, bool isfree, const char * lname) { if (l > TopAbs_VERTEX) return; TopExp_Explorer e; int count = 0; int count2 = 0; if (isfree) e.Init(sh, l, TopAbs_ShapeEnum(l-1)); else e.Init(sh, l); for (; e.More(); e.Next()) { count++; stringstream lname2; lname2 << lname << "/" << shapename[l] << count; str << lname2.str() << " "; switch (e.Current().ShapeType()) { case TopAbs_SOLID: count2 = somap.FindIndex(TopoDS::Solid(e.Current())); break; case TopAbs_SHELL: count2 = shmap.FindIndex(TopoDS::Shell(e.Current())); break; case TopAbs_FACE: count2 = fmap.FindIndex(TopoDS::Face(e.Current())); break; case TopAbs_WIRE: count2 = wmap.FindIndex(TopoDS::Wire(e.Current())); break; case TopAbs_EDGE: count2 = emap.FindIndex(TopoDS::Edge(e.Current())); break; case TopAbs_VERTEX: count2 = vmap.FindIndex(TopoDS::Vertex(e.Current())); break; default: cout << "RecursiveTopologyTree: Case " << e.Current().ShapeType() << " not handeled" << endl; } int nrsubshapes = 0; if (l <= TopAbs_WIRE) { TopExp_Explorer e2; for (e2.Init (e.Current(), TopAbs_ShapeEnum (l+1)); e2.More(); e2.Next()) nrsubshapes++; } str << "{" << shapename[l] << " " << count2; if (l <= TopAbs_EDGE) { str << " (" << orientationstring[e.Current().Orientation()]; if (nrsubshapes != 0) str << ", " << nrsubshapes; str << ") } "; } else str << " } "; RecursiveTopologyTree (e.Current(), str, TopAbs_ShapeEnum (l+1), false, (char*)lname2.str().c_str()); } } void OCCGeometry :: GetTopologyTree (stringstream & str) { cout << "Building topology tree ... " << flush; RecursiveTopologyTree (shape, str, TopAbs_COMPSOLID, false, "CompSolids"); RecursiveTopologyTree (shape, str, TopAbs_SOLID, true, "FreeSolids"); RecursiveTopologyTree (shape, str, TopAbs_SHELL, true, "FreeShells"); RecursiveTopologyTree (shape, str, TopAbs_FACE, true, "FreeFaces"); RecursiveTopologyTree (shape, str, TopAbs_WIRE, true, "FreeWires"); RecursiveTopologyTree (shape, str, TopAbs_EDGE, true, "FreeEdges"); RecursiveTopologyTree (shape, str, TopAbs_VERTEX, true, "FreeVertices"); str << flush; // cout << "done" << endl; } void OCCGeometry :: CheckIrregularEntities(stringstream & str) { ShapeAnalysis_CheckSmallFace csm; csm.SetTolerance (1e-6); TopTools_DataMapOfShapeListOfShape mapEdges; ShapeAnalysis_DataMapOfShapeListOfReal mapParam; TopoDS_Compound theAllVert; int spotfaces = 0; int stripsupportfaces = 0; int singlestripfaces = 0; int stripfaces = 0; int facessplitbyvertices = 0; int stretchedpinfaces = 0; int smoothpinfaces = 0; int twistedfaces = 0; // int edgessamebutnotidentified = 0; cout << "checking faces ... " << flush; int i; for (i = 1; i <= fmap.Extent(); i++) { TopoDS_Face face = TopoDS::Face (fmap(i)); TopoDS_Edge e1, e2; if (csm.CheckSpotFace (face)) { if (!spotfaces++) str << "SpotFace {Spot face} "; (*testout) << "Face " << i << " is a spot face" << endl; str << "SpotFace/Face" << i << " "; str << "{Face " << i << " } "; } if (csm.IsStripSupport (face)) { if (!stripsupportfaces++) str << "StripSupportFace {Strip support face} "; (*testout) << "Face " << i << " has strip support" << endl; str << "StripSupportFace/Face" << i << " "; str << "{Face " << i << " } "; } if (csm.CheckSingleStrip(face, e1, e2)) { if (!singlestripfaces++) str << "SingleStripFace {Single strip face} "; (*testout) << "Face " << i << " is a single strip (edge " << emap.FindIndex(e1) << " and edge " << emap.FindIndex(e2) << " are identical)" << endl; str << "SingleStripFace/Face" << i << " "; str << "{Face " << i << " (edge " << emap.FindIndex(e1) << " and edge " << emap.FindIndex(e2) << " are identical)} "; } if (csm.CheckStripFace(face, e1, e2)) { if (!stripfaces++) str << "StripFace {Strip face} "; (*testout) << "Face " << i << " is a strip (edge " << emap.FindIndex(e1) << " and edge " << emap.FindIndex(e2) << " are identical)" << endl; str << "StripFace/Face" << i << " "; str << "{Face " << i << " (edge " << emap.FindIndex(e1) << " and edge " << emap.FindIndex(e2) << " are identical)} "; } if (int count = csm.CheckSplittingVertices(face, mapEdges, mapParam, theAllVert)) { if (!facessplitbyvertices++) str << "FaceSplitByVertices {Face split by vertices} "; (*testout) << "Face " << i << " is split by " << count << " vertex/vertices " << endl; str << "FaceSplitByVertices/Face" << i << " "; str << "{Face " << i << " (split by " << count << "vertex/vertices)} "; } int whatrow, sens; if (int type = csm.CheckPin (face, whatrow, sens)) { if (type == 1) { if (!smoothpinfaces++) str << "SmoothPinFace {Smooth pin face} "; (*testout) << "Face " << i << " is a smooth pin" << endl; str << "SmoothPinFace/Face" << i << " "; str << "{Face " << i << " } "; } else { if (!stretchedpinfaces++) str << "StretchedPinFace {Stretched pin face} "; (*testout) << "Face " << i << " is a streched pin" << endl; str << "StretchedPinFace/Face" << i << " "; str << "{Face " << i << " } "; } } double paramu, paramv; if (csm.CheckTwisted (face, paramu, paramv)) { if (!twistedfaces++) str << "TwistedFace {Twisted face} "; (*testout) << "Face " << i << " is twisted" << endl; str << "TwistedFace/Face" << i << " "; str << "{Face " << i << " } "; } } cout << "done" << endl; cout << "checking edges ... " << flush; // double dmax; // int cnt = 0; Array edgeLengths; Array order; edgeLengths.SetSize (emap.Extent()); order.SetSize (emap.Extent()); for (i = 1; i <= emap.Extent(); i++) { TopoDS_Edge edge1 = TopoDS::Edge (emap(i)); GProp_GProps system; BRepGProp::LinearProperties(edge1, system); edgeLengths[i-1] = system.Mass(); } Sort (edgeLengths, order); str << "ShortestEdges {Shortest edges} "; for (i = 1; i <= min(20, emap.Extent()); i++) { str << "ShortestEdges/Edge" << i; str << " {Edge " << order[i-1] << " (L=" << edgeLengths[order[i-1]-1] << ")} "; } str << flush; cout << "done" << endl; } void OCCGeometry :: GetUnmeshedFaceInfo (stringstream & str) { for (int i = 1; i <= fmap.Extent(); i++) { if (facemeshstatus[i-1] == -1) str << "Face" << i << " {Face " << i << " } "; } str << flush; } void OCCGeometry :: GetNotDrawableFaces (stringstream & str) { for (int i = 1; i <= fmap.Extent(); i++) { if (!fvispar[i-1].IsDrawable()) str << "Face" << i << " {Face " << i << " } "; } str << flush; } bool OCCGeometry :: ErrorInSurfaceMeshing () { for (int i = 1; i <= fmap.Extent(); i++) if (facemeshstatus[i-1] == -1) return true; return false; } int OCCGeometry :: GenerateMesh (Mesh*& mesh, int perfstepsstart, int perfstepsend, char* optstring) { return OCCGenerateMesh (*this, mesh, perfstepsstart, perfstepsend, optstring); } const Refinement & OCCGeometry :: GetRefinement () const { return * new OCCRefinementSurfaces (*this); } OCCParameters :: OCCParameters() { resthcloseedgefac = 1; resthcloseedgeenable = 1; } void OCCParameters :: Print(ostream & ost) const { ost << "OCC Parameters:" << endl << "close edges: " << resthcloseedgeenable << ", fac = " << resthcloseedgefac << endl; } OCCParameters occparam; } #endif netgen-4.9.13/libsrc/occ/Partition_Loop3d.cxx0000644000175000001440000002406011244373410015745 00000000000000#ifdef OCCGEOMETRY // GEOM PARTITION : partition algorithm // // Copyright (C) 2003 CEA/DEN, EDF R&D // // // // File : Partition_Loop3d.cxx // Module : GEOM //using namespace std; #include #include "Partition_Loop3d.ixx" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //======================================================================= //function : Partition_Loop3d //purpose : //======================================================================= Partition_Loop3d::Partition_Loop3d() { } //======================================================================= //function : AddConstFaces //purpose : Add faces of as unique faces in the result. //======================================================================= void Partition_Loop3d::AddConstFaces(const TopoDS_Shape& S) { TopExp_Explorer FaceExp(S, TopAbs_FACE); for (; FaceExp.More(); FaceExp.Next()) myFaces.Append( FaceExp.Current() ); TopExp::MapShapesAndAncestors(S, TopAbs_EDGE, TopAbs_FACE, myEFMap); } //======================================================================= //function : AddSectionFaces //purpose : Add faces of as double faces in the result. //======================================================================= void Partition_Loop3d::AddSectionFaces(const TopoDS_Shape& S) { AddConstFaces( S ); AddConstFaces( S.Reversed() ); } //======================================================================= //function : MakeShells //purpose : Make and return shells. // can contain faces that must not be // added to result shells. //======================================================================= const TopTools_ListOfShape& Partition_Loop3d::MakeShells (const TopTools_MapOfOrientedShape& AvoidFacesMap) { myNewShells.Clear(); BRep_Builder Builder; TopTools_MapOfShape CheckedEdgesMap; TopTools_MapOfOrientedShape AddedFacesMap; TopTools_ListIteratorOfListOfShape itF (myFaces); for (; itF.More(); itF.Next()) { const TopoDS_Shape& FF = itF.Value(); if (AvoidFacesMap.Contains( FF ) || ! AddedFacesMap.Add( FF ) ) continue; // make a new shell TopoDS_Shell Shell; Builder.MakeShell(Shell); Builder.Add(Shell,FF); // clear the maps from shapes added to previous Shell TopTools_MapIteratorOfMapOfShape itEM (CheckedEdgesMap); for (; itEM.More(); itEM.Next()) { TopTools_ListOfShape& FL = myEFMap.ChangeFromKey( itEM.Key()); TopTools_ListIteratorOfListOfShape it (FL); while ( it.More()) { if (AddedFacesMap.Contains( it.Value())) FL.Remove( it ); else it.Next(); } } CheckedEdgesMap.Clear(); // loop on faces added to Shell; add their neighbor faces to Shell and so on TopoDS_Iterator itAddedF (Shell); for (; itAddedF.More(); itAddedF.Next()) { const TopoDS_Face& F = TopoDS::Face (itAddedF.Value()); // loop on edges of F; find a good neighbor face of F by E TopExp_Explorer EdgeExp(F, TopAbs_EDGE); for (; EdgeExp.More(); EdgeExp.Next()) { const TopoDS_Edge& E = TopoDS::Edge( EdgeExp.Current()); if (! CheckedEdgesMap.Add( E )) continue; // candidate faces list const TopTools_ListOfShape& FL = myEFMap.ChangeFromKey(E); if (FL.IsEmpty()) continue; // select one of neighbors TopoDS_Face SelF; if (FL.Extent() == 2) { if (! F.IsSame( FL.First() )) SelF = TopoDS::Face( FL.First() ); else if (!F.IsSame( FL.Last() )) SelF = TopoDS::Face( FL.Last() ); } else { // check if a face already added to Shell shares E TopTools_ListIteratorOfListOfShape it (FL); Standard_Boolean found = Standard_False; for (; !found && it.More(); it.Next()) if (F != it.Value()) found = AddedFacesMap.Contains( it.Value() ); if (found) continue; // select basing on geometrical check Standard_Boolean GoodOri, inside; Standard_Real dot, MaxDot = -100; TopTools_ListOfShape TangFL; // tangent faces for ( it.Initialize( FL ) ; it.More(); it.Next()) { const TopoDS_Face& NeighborF = TopoDS::Face( it.Value()); if (NeighborF.IsSame( F )) continue; inside = Partition_Loop3d::IsInside( E, F, NeighborF, 1, dot, GoodOri); if (!GoodOri) continue; if (!inside) dot = -dot - 3; if (dot < MaxDot) continue; if ( IsEqual( dot, MaxDot)) TangFL.Append(SelF); else TangFL.Clear(); MaxDot = dot; SelF = NeighborF; } if (!TangFL.IsEmpty()) { for (it.Initialize( TangFL ); it.More(); it.Next()) { const TopoDS_Face& NeighborF = TopoDS::Face( it.Value()); if (Partition_Loop3d:: IsInside( E, SelF , NeighborF, 0, dot, GoodOri)) SelF = NeighborF; } } } if (!SelF.IsNull() && AddedFacesMap.Add( SelF ) && !AvoidFacesMap.Contains( SelF )) Builder.Add( Shell, SelF); } // loop on edges of F } // loop on the faces added to Shell // Shell is complete myNewShells.Append( Shell ); } // loop on myFaces // prepare to the next call myFaces.Clear(); myEFMap.Clear(); return myNewShells; } //======================================================================= //function : Normal //purpose : //======================================================================= gp_Vec Partition_Loop3d::Normal(const TopoDS_Edge& E, const TopoDS_Face& F) { gp_Vec Norm, V1, V2; Standard_Real First, Last; gp_Pnt Ps; Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface (E, F, First, Last); Handle(Geom_Surface) Sf = BRep_Tool::Surface(F); gp_Pnt2d p = C2d->Value( 0.5*(First+Last) ); Sf->D1(p.X(), p.Y(), Ps, V1, V2); Norm = V1.Crossed(V2); if (F.Orientation() == TopAbs_REVERSED ) Norm.Reverse(); return Norm; } //======================================================================= //function : NextNormal //purpose : find normal to F at point a little inside F near the middle of E //warning : E must be properly oriented in F. //======================================================================= static gp_Vec NextNormal(const TopoDS_Edge& E, const TopoDS_Face& F) { Standard_Real First, Last; Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface (E, F, First, Last); Handle(Geom_Surface) Sf = BRep_Tool::Surface(F); gp_Pnt2d p; gp_Vec2d v; C2d->D1( 0.5*(First+Last), p, v); if (E.Orientation() != F.Orientation()) v.Reverse(); gp_Dir2d dir( -v.Y(), v.X() ); // dir inside F Standard_Real duv = 1e-6; // this is not Ok and may give incorrect result if // resolutionUV of compared faces is very different. To have a good result, //it is necessary to get normal to faces at points equidistant from E in 3D p.SetX( p.X() + dir.X()*duv ); p.SetY( p.Y() + dir.Y()*duv ); gp_Pnt Ps; gp_Vec Norm, V1, V2, VV1, VV2; Sf->D1( p.X(), p.Y(), Ps, V1, V2); Norm = V1.Crossed(V2); if (F.Orientation() == TopAbs_REVERSED ) Norm.Reverse(); return Norm; } //======================================================================= //function : FindEinF //purpose : find E in F //======================================================================= static TopoDS_Edge FindEinF(const TopoDS_Edge& E, const TopoDS_Face& F) { TopExp_Explorer expl (F, TopAbs_EDGE); for (; expl.More(); expl.Next()) if( E.IsSame( expl.Current() )) return TopoDS::Edge(expl.Current()); TopoDS_Edge nullE; return nullE; } //======================================================================= //function : IsInside //purpose : check if is inside by edge . // if , compute : scalar production of // normalized vectors pointing inside faces, and // check if faces are oriented well for sewing //======================================================================= Standard_Boolean Partition_Loop3d::IsInside(const TopoDS_Edge& E, const TopoDS_Face& F1, const TopoDS_Face& F2, const Standard_Boolean CountDot, Standard_Real& Dot, Standard_Boolean& GoodOri) { Standard_Real f, l; gp_Pnt P; gp_Vec Vc1, Vc2, Vin1, Vin2, Nf1, Nf2; Handle(Geom_Curve) Curve = BRep_Tool::Curve(E,f,l); Curve->D1( 0.5*(f + l), P, Vc2); TopoDS_Edge E1, E2 = FindEinF (E, F2); if (E2.Orientation() == TopAbs_REVERSED ) Vc2.Reverse(); Nf1 = Normal(E,F1); Nf2 = Normal(E,F2); Standard_Real sin = Nf1.CrossSquareMagnitude(Nf2) / Nf1.SquareMagnitude() / Nf2.SquareMagnitude(); Standard_Boolean tangent = sin < 0.001; Standard_Boolean inside = 0; if (tangent) { E1 = FindEinF (E, F1); gp_Vec NNf1 = NextNormal(E1,F1); gp_Vec NNf2 = NextNormal(E2,F2); Vin2 = NNf2.Crossed(Vc2); inside = Vin2 * NNf1 < 0; } else { Vin2 = Nf2.Crossed(Vc2); inside = Vin2 * Nf1 < 0; } if (!CountDot) return inside; if (tangent) Vin2 = Nf2.Crossed(Vc2); else E1 = FindEinF (E, F1); Vc1 = Vc2; if (E1.Orientation() != E2.Orientation()) Vc1.Reverse(); Vin1 = Nf1.Crossed(Vc1); if (tangent) { Standard_Real N1N2 = Nf1 * Nf2; GoodOri = (Vin2 * Vin1 < 0) ? N1N2 > 0 : N1N2 < 0; } else { Standard_Real V1N2 = Vin1 * Nf2; GoodOri = ( inside ? V1N2 <= 0 : V1N2 >= 0); } Vin1.Normalize(); Vin2.Normalize(); Dot = Vin2 * Vin1; return inside; } #endif netgen-4.9.13/libsrc/occ/Partition_Inter2d.cxx0000644000175000001440000005543011244373410016121 00000000000000#ifdef OCCGEOMETRY // GEOM PARTITION : partition algorithm // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R& D, LEG, PRINCIPIA R& D, BUREAU VERITAS // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // // File : Partition_Inter2d.cxx // Author : Benedicte MARTIN // Module : GEOM // $Header: /cvs/netgen/netgen/libsrc/occ/Partition_Inter2d.cxx,v 1.5 2008/03/31 14:20:28 wabro Exp $ //using namespace std; #include "Partition_Inter2d.ixx" #include "utilities.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef DEB static Standard_Boolean TestEdges = 0; static Standard_Integer NbF2d = 0; static Standard_Integer NbE2d = 0; #endif //======================================================================= //function : getOtherShape //purpose : //======================================================================= static TopoDS_Shape getOtherShape(const TopoDS_Shape& theS, const TopTools_ListOfShape& theSList) { TopTools_ListIteratorOfListOfShape anIt( theSList ); for ( ; anIt.More(); anIt.Next() ) if (!theS.IsSame( anIt.Value() )) return anIt.Value(); return TopoDS_Shape(); } //======================================================================= //function : findVOnE //purpose : on theE, find a vertex close to theV, such that an edge // passing through it is an itersection of theF1 and theF2. // theE intersects theE2 at theV //======================================================================= static Standard_Boolean findVOnE(const TopoDS_Vertex & theV, const TopoDS_Edge& theE, const TopoDS_Edge& theE2, const TopoDS_Shape& theF1, const TopoDS_Shape& theF2, const Handle(BRepAlgo_AsDes)& theAsDes, TopoDS_Vertex & theFoundV) { Standard_Real MinDist2 = ::RealLast(); gp_Pnt P; // check all vertices on theE const TopTools_ListOfShape& aVList = theAsDes->Descendant( theE ); TopTools_ListIteratorOfListOfShape anIt( aVList ); if (anIt.More()) P = BRep_Tool::Pnt( theV ); for ( ; anIt.More(); anIt.Next() ) { // check by distance TopoDS_Vertex & V = TopoDS::Vertex( anIt.Value() ); Standard_Real dist2 = P.SquareDistance( BRep_Tool::Pnt( V )); if (dist2 < MinDist2) MinDist2 = dist2; else continue; // V is a candidate if among edges passing through V there is one // which is an intersection of theF1 and theF2 TopTools_ListIteratorOfListOfShape anEIt( theAsDes->Ascendant( V )); Standard_Boolean isOk = Standard_False; for ( ; !isOk && anEIt.More(); anEIt.Next() ) { const TopoDS_Shape & E2 = anEIt.Value(); if ( theE2.IsSame( E2 )) continue; const TopTools_ListOfShape & aFList = theAsDes->Ascendant( E2 ); if (aFList.IsEmpty()) continue; if ( theF1.IsSame( aFList.First() )) isOk = theF2.IsSame( aFList.Last() ); else isOk = theF2.IsSame( aFList.First() ) && theF1.IsSame( aFList.Last() ); } if (isOk) theFoundV = V; } if (theFoundV.IsNull()) return Standard_False; // check that MinDist2 is not too large Standard_Real f, l; TopLoc_Location L; Handle(Geom_Curve) aCurve = BRep_Tool::Curve( theE, L, f, l ); gp_Pnt P1 = aCurve->Value( f ); gp_Pnt P2 = aCurve->Value( 0.3 * f + 0.7 * l ); //gp_Pnt P2 = aCurve->Value( 0.5 * ( f + l )); if (MinDist2 > P1.SquareDistance( P2 )) return Standard_False; #ifdef DEB MESSAGE("findVOnE: found MinDist = " << sqrt (MinDist2)); #endif return Standard_True; } //======================================================================= //function : AddVonE //purpose : Put V in AsDes as intersection of E1 and E2. // Check that vertex equal to V already exists on one // of edges, in such a case, V is not added but // existing vertex is updated to be on E1 and E2 and // is returned insead of V. //======================================================================= TopoDS_Vertex Partition_Inter2d::AddVonE(const TopoDS_Vertex& theV, const TopoDS_Edge& E1, const TopoDS_Edge& E2, const Handle(BRepAlgo_AsDes)& AsDes, const TopoDS_Face& theF) { //------------------------------------------------------------- // test if the points of intersection already exist. If not, // add as descendants of the edges. // nb: theses points are only vertices of intersection. //------------------------------------------------------------- const TopTools_ListOfShape& VOnE1 = AsDes->Descendant(E1); const TopTools_ListOfShape& VOnE2 = AsDes->Descendant(E2); gp_Pnt P1,P2; TopoDS_Vertex V1,V2; TopTools_ListIteratorOfListOfShape it; BRep_Builder B; TopAbs_Orientation O1,O2; Standard_Real U1,U2; Standard_Real Tol,Tol1,Tol2; Standard_Boolean OnE1,OnE2; TopoDS_Vertex V = theV; U1 = BRep_Tool::Parameter(V,E1); U2 = BRep_Tool::Parameter(V,E2); O1 = V.Orientation(); O2 = O1; P1 = BRep_Tool::Pnt(V); Tol = BRep_Tool::Tolerance( V ); OnE1 = OnE2 = Standard_False; //----------------------------------------------------------------- // Search if the point of intersection is a vertex of E1. //----------------------------------------------------------------- for (it.Initialize(VOnE1); it.More(); it.Next()) { const TopoDS_Vertex& CV = TopoDS::Vertex( it.Value() ); if (V.IsSame( CV )) { V1 = V; OnE1 = Standard_True; break; } P2 = BRep_Tool::Pnt( CV ); Tol1 = 1.1*(Tol + BRep_Tool::Tolerance( CV )); if (P1.SquareDistance(P2) <= Tol1*Tol1) { V = CV; V1 = V; OnE1 = Standard_True; break; } } if (OnE1) { //----------------------------------------------------------------- // Search if the vertex found is still on E2. //----------------------------------------------------------------- for (it.Initialize(VOnE2); it.More(); it.Next()) { if (V.IsSame( it.Value() )) { OnE2 = Standard_True; V2 = V; break; } } } if (!OnE2) { for (it.Initialize(VOnE2); it.More(); it.Next()) { //----------------------------------------------------------------- // Search if the point of intersection is a vertex of E2. //----------------------------------------------------------------- const TopoDS_Vertex& CV = TopoDS::Vertex( it.Value() ); P2 = BRep_Tool::Pnt( CV ); Tol2 = 1.1*(Tol + BRep_Tool::Tolerance( CV )); if (P1.SquareDistance(P2) <= Tol2*Tol2) { V = CV; V2 = V; OnE2 = Standard_True; break; } } } if (!OnE1 && !OnE2 && !theF.IsNull()) { // if 3 faces intersects each others, 3 new edges on them must pass // through one vertex but real intersection points of each // pair of edges are sometimes more far than a tolerance. // Try to analitically find vertices that E1 and E2 must pass trough TopoDS_Shape F1 = getOtherShape( theF, AsDes->Ascendant( E1 )); TopoDS_Shape F2 = getOtherShape( theF, AsDes->Ascendant( E2 )); if (!F1.IsNull() && !F2.IsNull() && !F1.IsSame( F2 )) { OnE1 = findVOnE ( theV, E1, E2, F1, F2, AsDes, V1 ); OnE2 = findVOnE ( theV, E2, E1, F1, F2, AsDes, V2 ); if (OnE2) V = V2; if (OnE1) V = V1; } } if (OnE1 && OnE2) { if (!V1.IsSame(V2)) { // replace V1 with V2 on all edges V1 is on Standard_Real UV1; TopoDS_Edge EWE1; TopoDS_Vertex VI; const TopTools_ListOfShape& EdgeWithV1 = AsDes->Ascendant(V1); for (it.Initialize(EdgeWithV1); it.More(); it.Next()) { EWE1 = TopoDS::Edge(it.Value()); VI = V1; VI.Orientation(TopAbs_INTERNAL); UV1 = BRep_Tool::Parameter(VI,EWE1); VI = V2; VI.Orientation(TopAbs_INTERNAL); B.UpdateVertex( VI, UV1, EWE1, GetTolerance( VI, UV1, EWE1, AsDes)); } AsDes->Replace(V1,V2); V = V2; } } // add existing vertices instead of new ones if (!OnE1) { if (OnE2) { V.Orientation(TopAbs_INTERNAL); B.UpdateVertex (V, U1, E1, GetTolerance( V, U1, E1, AsDes)); } V.Orientation(O1); AsDes->Add(E1,V); } if (!OnE2) { if (OnE1) { V.Orientation(TopAbs_INTERNAL); B.UpdateVertex (V, U2, E2, GetTolerance( V, U2, E2, AsDes )); } V.Orientation(O2); AsDes->Add(E2,V); } return V; } //======================================================================= //function : FindEndVertex //purpose : Returns a vertex from having parameter on // closest to or . is True if // found vertex is closer to . returns parameter // difference. //======================================================================= TopoDS_Vertex Partition_Inter2d::FindEndVertex(const TopTools_ListOfShape& LV, const Standard_Real f, const Standard_Real l, const TopoDS_Edge& E, Standard_Boolean& isFirst, Standard_Real& minDU) { TopoDS_Vertex endV; Standard_Real U, endU, min; minDU = 1.e10; TopTools_ListIteratorOfListOfShape it; it.Initialize(LV); for (; it.More(); it.Next()) { const TopoDS_Vertex& v = TopoDS::Vertex(it.Value()); U = BRep_Tool::Parameter(v, E); min = Min( Abs(U-f), Abs(U-l) ); if (min < minDU) { endV = v; endU = U; minDU = min; } } if (Abs(endU-f) < Abs(endU-l)) isFirst = Standard_True; else isFirst = Standard_False; return endV; } //======================================================================= //function : treatClosed //purpose : add second vertex to closed edge. Vertex is one of //======================================================================= static void treatClosed (const TopoDS_Edge& E1, const Standard_Real f, const Standard_Real l, TopTools_ListOfShape& LV1, TopTools_ListOfShape& /*LV2*/) { Standard_Boolean isFirst=0; Standard_Real minDU = 1.e10; TopoDS_Vertex endV; endV = Partition_Inter2d::FindEndVertex(LV1, f,l, E1, isFirst,minDU); if (minDU > Precision::PConfusion()) return; // not end point Standard_Real newU; if (isFirst) newU = f + (l - f); else newU = l - (l - f); // update end parameter BRep_Builder B; endV.Orientation(TopAbs_INTERNAL); B.UpdateVertex(endV,newU,E1,BRep_Tool::Tolerance(endV)); } //======================================================================= //function : EdgesPartition //purpose : //======================================================================= static void EdgesPartition(const TopoDS_Face& F, const TopoDS_Edge& E1, const TopoDS_Edge& E2, const Handle(BRepAlgo_AsDes)& AsDes, const TopTools_MapOfShape& NewEdges, const Standard_Boolean WithOri) { Standard_Real f[3],l[3]; Standard_Real MilTol2; Standard_Real Tol = Max (BRep_Tool::Tolerance(E1), BRep_Tool::Tolerance(E2)); MilTol2 = Tol * Tol * 10; BRep_Tool::Range(E1, f[1], l[1]); BRep_Tool::Range(E2, f[2], l[2]); BRepAdaptor_Curve CE1(E1,F); BRepAdaptor_Curve CE2(E2,F); TopoDS_Edge EI[3]; EI[1] = E1; EI[2] = E2; TopTools_ListOfShape LV1; // new vertices at intersections on E1 TopTools_ListOfShape LV2; // ... on E2 BRep_Builder B; // if E1 and E2 are results of intersection of F and two connex faces then // no need to intersect edges, they can contact by vertices only // (encounted an exception in TopOpeBRep_EdgesIntersector in such a case) Standard_Boolean intersect = Standard_True; TopTools_IndexedMapOfShape ME; TopExp::MapShapes(F, TopAbs_EDGE, ME); if (!ME.Contains(E1) && ! ME.Contains(E2)) { // if E1 and E2 are new on F TopoDS_Shape F1, F2; const TopTools_ListOfShape& LF1 = AsDes->Ascendant( E1 ); F1 = F.IsSame( LF1.First() ) ? LF1.Last() : LF1.First(); const TopTools_ListOfShape& LF2 = AsDes->Ascendant( E2 ); F2 = F.IsSame( LF2.First() ) ? LF2.Last() : LF2.First(); if (!F.IsSame(F2) && !F.IsSame(F1) ) { TopExp_Explorer exp(F2, TopAbs_EDGE); TopExp::MapShapes(F1, TopAbs_EDGE, ME); for (; exp.More(); exp.Next()) { if (ME.Contains( exp.Current())) { intersect = Standard_False; break; } } } } if (intersect) { //------------------------------------------------------ // compute the points of Intersection in 2D //----------------------------------------------------- // i.e. fill LV1 and LV2 TopOpeBRep_EdgesIntersector EInter; EInter.SetFaces(F,F); Standard_Real TolDub = 1.e-7; EInter.ForceTolerances(TolDub,TolDub); Standard_Boolean reducesegments = Standard_False; EInter.Perform (E1,E2,reducesegments); Standard_Boolean rejectreducedsegmentpoints = Standard_False; EInter.InitPoint(rejectreducedsegmentpoints); for ( ; EInter.MorePoint(); EInter.NextPoint() ) { const TopOpeBRep_Point2d& P2D = EInter.Point(); const gp_Pnt& P = P2D.Value(); TopoDS_Vertex V = BRepLib_MakeVertex(P); //------------------------- // control the point found. //------------------------- gp_Pnt P1 = CE1.Value(P2D.Parameter(1)); gp_Pnt P2 = CE2.Value(P2D.Parameter(2)); Standard_Real sqd1 = P1.SquareDistance(P); Standard_Real sqd2 = P2.SquareDistance(P); if (sqd1 > MilTol2 || sqd2 > MilTol2 ) continue; // add a new vertex to the both edges Standard_Real toler = Max( Tol, sqrt( Max( sqd1, sqd2 ))); Standard_Integer i; for (i = 1; i <= 2; i++) { Standard_Real U = P2D.Parameter(i); V.Orientation(TopAbs_INTERNAL); B.UpdateVertex( V,U,EI[i], toler); TopAbs_Orientation OO = TopAbs_REVERSED; if (WithOri) { if (P2D.IsVertex(i)) OO = P2D.Vertex(i).Orientation(); else if (P2D.Transition(i).Before() == TopAbs_OUT) { OO = TopAbs_FORWARD; } V.Orientation(OO); if (i == 1) LV1.Append(V); else LV2.Append(V); } } } } // if (intersect) //---------------------------------- // Test the extremities of the edges. //---------------------------------- // add to LV* vertices for vertex-vertex closeness Standard_Real U1,U2; Standard_Real TolConf2, TolConf; TopoDS_Vertex V1[2],V2[2]; TopExp::Vertices(E1,V1[0],V1[1]); TopExp::Vertices(E2,V2[0],V2[1]); Standard_Integer i,j,k; for (j = 0; j < 2; j++) { if (V1[j].IsNull()) continue; for ( k = 0; k < 2; k++) { if (V2[k].IsNull()) continue; gp_Pnt P1 = BRep_Tool::Pnt(V1[j]); gp_Pnt P2 = BRep_Tool::Pnt(V2[k]); TolConf = BRep_Tool::Tolerance(V1[j]) + BRep_Tool::Tolerance(V2[k]); TolConf = Max (Tol, TolConf); TolConf2 = TolConf * TolConf; if (!intersect) TolConf2 *= 100; Standard_Real SqDist = P1.SquareDistance(P2); if (SqDist <= TolConf2) { TopoDS_Vertex V = BRepLib_MakeVertex(P1); V.Orientation(TopAbs_INTERNAL); U1 = (j == 0) ? f[1] : l[1]; U2 = (k == 0) ? f[2] : l[2]; B.UpdateVertex(V,U1,E1,TolConf); B.UpdateVertex(V,U2,E2,TolConf); LV1.Prepend(V.Oriented(V1[j].Orientation())); LV2.Prepend(V.Oriented(V2[k].Orientation())); } } } Standard_Boolean AffichPurge = Standard_False; if ( LV1.IsEmpty()) return; //---------------------------------- // Purge of all the vertices. //---------------------------------- // remove one of close vertices TopTools_ListIteratorOfListOfShape it1LV1,it1LV2,it2LV1; gp_Pnt P1,P2; Standard_Boolean Purge = Standard_True; while (Purge) { i = 1; Purge = Standard_False; for (it1LV1.Initialize(LV1),it1LV2.Initialize(LV2); it1LV1.More(); it1LV1.Next(),it1LV2.Next()) { j = 1; it2LV1.Initialize(LV1); while (j < i) { const TopoDS_Vertex& VE1 = TopoDS::Vertex(it1LV1.Value()); const TopoDS_Vertex& VE2 = TopoDS::Vertex(it2LV1.Value()); Standard_Real Tol1 = BRep_Tool::Tolerance( VE1 ); Standard_Real Tol2 = BRep_Tool::Tolerance( VE2 ); P1 = BRep_Tool::Pnt( VE1 ); P2 = BRep_Tool::Pnt( VE2 ); if (P1.IsEqual(P2, Tol1 + Tol2)) { LV1.Remove(it1LV1); LV2.Remove(it1LV2); Purge = Standard_True; break; } j++; it2LV1.Next(); } if (Purge) break; i++; } } // care of new closed edges, they always intersect with seam at end if (V1[0].IsSame( V1[1] ) && NewEdges.Contains(E1) ) treatClosed (E1, f[1], l[1], LV1, LV2); if (V2[0].IsSame( V2[1] ) && NewEdges.Contains(E2) ) treatClosed (E2, f[2], l[2], LV2, LV1); //---------------- // Stocking vertex //---------------- for ( it1LV1.Initialize( LV1 ); it1LV1.More(); it1LV1.Next()) Partition_Inter2d::AddVonE (TopoDS::Vertex( it1LV1.Value()), E1, E2, AsDes, F); } //======================================================================= //function : CompletPart2d //purpose : Computes the intersections between the edges stored // is AsDes as descendants of . Intersections is computed // between two edges if one of them is bound in NewEdges. //======================================================================= void Partition_Inter2d::CompletPart2d (const Handle(BRepAlgo_AsDes)& AsDes, const TopoDS_Face& F, const TopTools_MapOfShape& NewEdges) { #ifdef DEB NbF2d++; NbE2d = 0; #endif //Do not intersect the edges of a face TopTools_IndexedMapOfShape EdgesOfFace; TopExp::MapShapes( F, TopAbs_EDGE , EdgesOfFace); //------------------------------------------------------------------- // compute the intersection2D on the faces touched by the intersection3D //------------------------------------------------------------------- TopTools_ListIteratorOfListOfShape it1LE ; TopTools_ListIteratorOfListOfShape it2LE ; //----------------------------------------------- // Intersection edge-edge. //----------------------------------------------- const TopTools_ListOfShape& LE = AsDes->Descendant(F); TopoDS_Vertex V1,V2; Standard_Integer j, i = 1; TopoDS_Face FF = F; FF.Orientation(TopAbs_FORWARD); for ( it1LE.Initialize(LE) ; it1LE.More(); it1LE.Next()) { const TopoDS_Edge& E1 = TopoDS::Edge(it1LE.Value()); j = 1; it2LE.Initialize(LE); while (j < i && it2LE.More()) { const TopoDS_Edge& E2 = TopoDS::Edge(it2LE.Value()); //---------------------------------------------------------- // Intersections of the new edges obtained by intersection // between them and with the restrictions edges //---------------------------------------------------------- if ( (!EdgesOfFace.Contains(E1) || !EdgesOfFace.Contains(E2)) && (NewEdges.Contains(E1) || NewEdges.Contains(E2)) ) { EdgesPartition(FF,E1,E2,AsDes,NewEdges,Standard_True); } it2LE.Next(); j++; } i++; } } //======================================================================= //function : GetTolerance //purpose : Returns tolerance theV must have atfer its // addition to theE with theU parameter. theAsDes is // used to find pcurves of theE //======================================================================= Standard_Real Partition_Inter2d::GetTolerance (const TopoDS_Vertex & theV, const Standard_Real theU, const TopoDS_Edge & theE, const Handle(BRepAlgo_AsDes)& theAsDes) { Standard_Real aTol = BRep_Tool::Tolerance( theV ); gp_Pnt aPnt = BRep_Tool::Pnt( theV ); // check point on 3D curve Standard_Real f,l; Handle(Geom_Curve) C = BRep_Tool::Curve( theE, f, l ); if (!C.IsNull()) aTol = Max ( aTol, aPnt.Distance( C->Value( theU ))); // check points on pcurves const TopTools_ListOfShape& aFList = theAsDes->Ascendant( theE ); TopTools_ListIteratorOfListOfShape aFIt( aFList ); for ( ; aFIt.More(); aFIt.Next() ) { const TopoDS_Face& F = TopoDS::Face( aFIt.Value() ); Handle(Geom2d_Curve) pcurve = BRep_Tool::CurveOnSurface( theE, F, f, l ); if (!pcurve.IsNull()) { gp_Pnt2d aPnt2d = pcurve->Value( theU ); TopLoc_Location L; Handle(Geom_Surface) S = BRep_Tool::Surface( F, L ); gp_Pnt aPntOnS = S->Value( aPnt2d.X(), aPnt2d.Y() ); if (!L.IsIdentity()) aPntOnS.Transform( L.Transformation() ); aTol = Max ( aTol, aPnt.Distance( aPntOnS )); } } return aTol; } #endif netgen-4.9.13/libsrc/occ/Partition_Loop.hxx0000644000175000001440000000527311244373410015530 00000000000000// GEOM PARTITION : partition algorithm // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // // File : Partition_Loop.hxx // Module : GEOM #ifndef _Partition_Loop_HeaderFile #define _Partition_Loop_HeaderFile #ifndef _TopoDS_Face_HeaderFile #include #endif #ifndef _TopTools_ListOfShape_HeaderFile #include #endif #ifndef _TopTools_DataMapOfShapeListOfShape_HeaderFile #include #endif class TopoDS_Face; class TopoDS_Edge; class TopTools_ListOfShape; #ifndef _Standard_HeaderFile #include #endif #ifndef _Standard_Macro_HeaderFile #include #endif class Partition_Loop { public: inline void* operator new(size_t,void* anAddress) { return anAddress; } inline void* operator new(size_t size) { return Standard::Allocate(size); } inline void operator delete(void *anAddress) { if (anAddress) Standard::Free((Standard_Address&)anAddress); } // inline void operator delete(void *anAddress, size_t size) // { // if (anAddress) Standard::Free((Standard_Address&)anAddress,size); // } // Methods PUBLIC // Partition_Loop(); void Init(const TopoDS_Face& F) ; void AddConstEdge(const TopoDS_Edge& E) ; void Perform() ; const TopTools_ListOfShape& NewWires() const; void WiresToFaces() ; const TopTools_ListOfShape& NewFaces() const; protected: // Methods PROTECTED // // Fields PROTECTED // private: // Methods PRIVATE // // Fields PRIVATE // TopoDS_Face myFace; TopTools_ListOfShape myConstEdges; TopTools_ListOfShape myNewWires; TopTools_ListOfShape myNewFaces; }; // other inline functions and methods (like "C++: function call" methods) // #endif netgen-4.9.13/libsrc/occ/Partition_Inter3d.ixx0000644000175000001440000000207111244373410016121 00000000000000// GEOM PARTITION : partition algorithm // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // // File : Partition_Inter3d.ixx // Module : GEOM #include "Partition_Inter3d.jxx" netgen-4.9.13/libsrc/occ/Partition_Loop3d.hxx0000644000175000001440000000376511244373410015763 00000000000000// GEOM PARTITION : partition algorithm // // Copyright (C) 2003 CEA/DEN, EDF R&D // // // // File : Partition_Loop3d.hxx // Module : GEOM #ifndef _Partition_Loop3d_HeaderFile #define _Partition_Loop3d_HeaderFile #ifndef _TopTools_ListOfShape_HeaderFile #include #endif #ifndef _TopTools_IndexedDataMapOfShapeListOfShape_HeaderFile #include #endif #ifndef _Standard_Boolean_HeaderFile #include #endif #ifndef _Standard_Real_HeaderFile #include #endif class TopoDS_Shape; class TopTools_ListOfShape; class TopTools_MapOfOrientedShape; class TopoDS_Edge; class TopoDS_Face; class gp_Vec; #ifndef _Standard_HeaderFile #include #endif #ifndef _Standard_Macro_HeaderFile #include #endif class Partition_Loop3d { public: void* operator new(size_t,void* anAddress) { return anAddress; } void* operator new(size_t size) { return Standard::Allocate(size); } void operator delete(void *anAddress) { if (anAddress) Standard::Free((Standard_Address&)anAddress); } // Methods PUBLIC // Partition_Loop3d(); void AddConstFaces(const TopoDS_Shape& S) ; void AddSectionFaces(const TopoDS_Shape& S) ; const TopTools_ListOfShape& MakeShells(const TopTools_MapOfOrientedShape& AvoidFacesMap) ; static Standard_Boolean IsInside(const TopoDS_Edge& E,const TopoDS_Face& F1,const TopoDS_Face& F2,const Standard_Boolean CountDot,Standard_Real& Dot,Standard_Boolean& GoodOri) ; static gp_Vec Normal(const TopoDS_Edge& E,const TopoDS_Face& F) ; protected: // Methods PROTECTED // // Fields PROTECTED // private: // Methods PRIVATE // // Fields PRIVATE // TopTools_ListOfShape myNewShells; TopTools_ListOfShape myFaces; TopTools_IndexedDataMapOfShapeListOfShape myEFMap; }; // other Inline functions and methods (like "C++: function call" methods) // #endif netgen-4.9.13/libsrc/occ/Partition_Inter2d.ixx0000644000175000001440000000211411244373410016116 00000000000000// GEOM PARTITION : partition algorithm // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // // File : Partition_Inter2d.ixx // Module : GEOM #include #include "Partition_Inter2d.jxx" netgen-4.9.13/libsrc/occ/Partition_Loop.ixx0000644000175000001440000000206311244373410015523 00000000000000// GEOM PARTITION : partition algorithm // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // // File : Partition_Loop.ixx // Module : GEOM #include "Partition_Loop.jxx" netgen-4.9.13/libsrc/occ/Partition_Loop3d.jxx0000644000175000001440000000122511244373410015752 00000000000000// GEOM PARTITION : partition algorithm // // Copyright (C) 2003 CEA/DEN, EDF R&D // // // // File : Partition_Loop3d.jxx // Module : GEOM #ifndef _TopoDS_Shape_HeaderFile #include #endif #ifndef _TopTools_ListOfShape_HeaderFile #include #endif #ifndef _TopTools_MapOfOrientedShape_HeaderFile #include #endif #ifndef _TopoDS_Edge_HeaderFile #include #endif #ifndef _TopoDS_Face_HeaderFile #include #endif #ifndef _gp_Vec_HeaderFile #include #endif #ifndef _Partition_Loop3d_HeaderFile #include "Partition_Loop3d.hxx" #endif netgen-4.9.13/libsrc/occ/Partition_Spliter.cxx0000644000175000001440000021004511244373410016227 00000000000000#ifdef OCCGEOMETRY // GEOM PARTITION : partition algorithm // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // // File : Partition_Spliter.cxx // Author : Benedicte MARTIN // Module : GEOM // $Header: /cvs/netgen/netgen/libsrc/occ/Partition_Spliter.cxx,v 1.7 2008/03/31 14:20:28 wabro Exp $ //using namespace std; #include #include "Partition_Inter2d.hxx" #include "Partition_Inter3d.hxx" #include "Partition_Loop2d.hxx" #include "Partition_Loop3d.hxx" #include "Partition_Spliter.ixx" #include "utilities.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef DEB //# define PART_PERF #endif #ifdef PART_PERF # include #endif //======================================================================= //function : isClosed //purpose : check id a shape is closed, ie is a solid or a closed shell //======================================================================= static Standard_Boolean isClosed(const TopoDS_Shape& theShape) { Standard_Boolean isClosed = (theShape.ShapeType() == TopAbs_SOLID); if (!isClosed && theShape.ShapeType() == TopAbs_SHELL) { TopTools_IndexedDataMapOfShapeListOfShape MEF; TopExp::MapShapesAndAncestors(theShape, TopAbs_EDGE, TopAbs_FACE, MEF); for (Standard_Integer i=1; isClosed && i<=MEF.Extent(); ++i) isClosed = ( MEF(i).Extent() != 1 ); } return isClosed; } //======================================================================= //function : Partition_Spliter //purpose : constructor //======================================================================= Partition_Spliter::Partition_Spliter() { myAsDes = new BRepAlgo_AsDes; Clear(); } //======================================================================= //function : AddTool //purpose : add cutting tool that will _NOT_ be in result //======================================================================= void Partition_Spliter::AddTool(const TopoDS_Shape& S) { if (S.ShapeType() < TopAbs_SOLID) { // compound or compsolid TopoDS_Iterator it (S); for (; it.More(); it.Next()) { AddTool( it.Value()); myFaceShapeMap.Bind( it.Value(), S ); // to know compound by shape } return; } for (TopExp_Explorer exp(S,TopAbs_FACE); exp.More(); exp.Next()) { myMapTools.Add(exp.Current()); myFaceShapeMap.Bind( exp.Current(), S ); } if (isClosed( S )) myClosedShapes.Add( S ); } //======================================================================= //function : AddShape //purpose : add object Shape to be splited //======================================================================= void Partition_Spliter::AddShape(const TopoDS_Shape& S) { if (S.ShapeType() < TopAbs_SOLID) { // compound or compsolid TopoDS_Iterator it (S); for (; it.More(); it.Next()) { AddShape( it.Value()); myFaceShapeMap.Bind( it.Value(), S ); // to know compound by shape } return; } TopExp_Explorer exp(S,TopAbs_FACE); if (!exp.More()) { // do not split edges and vertices //myBuilder.Add( myShape, S ); return; } Standard_Integer nbFacesBefore = myMapFaces.Extent(); // not to add twice the same S for (; exp.More(); exp.Next()) { const TopoDS_Shape & aFace = exp.Current(); if ( ! myFaceShapeMap.IsBound( aFace )) // keep shape of tool face added as object myFaceShapeMap.Bind( aFace, S ); if (myMapFaces.Add( aFace )) myImagesFaces.SetRoot( aFace ); } if (nbFacesBefore == myMapFaces.Extent()) return; // solids must be processed before all if (S.ShapeType() == TopAbs_SOLID) myListShapes.Prepend(S); else myListShapes.Append(S); if (isClosed( S )) myClosedShapes.Add( S ); } //======================================================================= //function : Shape //purpose : return resulting compound //======================================================================= TopoDS_Shape Partition_Spliter::Shape() const { return myShape; } //======================================================================= //function : Clear //purpose : clear fields //======================================================================= void Partition_Spliter::Clear() { myDoneStep = TopAbs_SHAPE; myListShapes.Clear(); myMapFaces.Clear(); myMapTools.Clear(); myEqualEdges.Clear(); myNewSection.Clear(); myClosedShapes.Clear(); mySharedFaces.Clear(); myWrappingSolid.Clear(); myFaceShapeMap.Clear(); myInternalFaces.Clear(); myIntNotClFaces.Clear(); myAsDes->Clear(); myImagesFaces.Clear(); myImagesEdges.Clear(); myImageShape.Clear(); // myInter3d = Partition_Inter3d(myAsDes); Partition_Inter3d hinter3d (myAsDes); myInter3d = hinter3d; myAddedFacesMap.Clear(); } //======================================================================= //function : Compute //purpose : produce a result //======================================================================= void Partition_Spliter::Compute(const TopAbs_ShapeEnum Limit) { if ((Limit != TopAbs_SHAPE && myDoneStep == Limit) || (Limit == TopAbs_SHAPE && myDoneStep == TopAbs_SOLID)) return; myBuilder.MakeCompound( myShape ); TopTools_MapIteratorOfMapOfShape it; TopTools_ListIteratorOfListOfShape itl; TopExp_Explorer exp; #ifdef PART_PERF OSD_Chronometer aCron; #endif if (myDoneStep > TopAbs_VERTEX) { TopTools_ListOfShape aListFaces; aListFaces = myImagesFaces.Roots(); for (it.Initialize(myMapTools); it.More(); it.Next()) aListFaces.Append(it.Key()); #ifdef PART_PERF aCron.Start(); #endif //----------------------------------------------- // Intersection between faces //----------------------------------------------- // result is in myAsDes as a map Face - list of new edges; // special care is done for section edges, same domain faces and vertices: // data about them is inside myInter3d myInter3d.CompletPart3d(aListFaces, myFaceShapeMap); #ifdef PART_PERF MESSAGE("+++ CompletPart3d()"); aCron.Show( cout ); aCron.Reset(); aCron.Start(); #endif //----------------------------------------------- // Intersection of edges //----------------------------------------------- // add tool faces which must be reconstructed to myMapFaces too FindToolsToReconstruct(); #ifdef PART_PERF MESSAGE("+++ FindToolsToReconstruct()"); aCron.Show( cout ); aCron.Reset(); aCron.Start(); #endif // add existing vertices to edges of object faces in myAsDes TopTools_MapOfShape DoneEM; for ( it.Initialize(myMapFaces); it.More(); it.Next()) { const TopoDS_Shape& F = it.Key(); TopoDS_Face FForward = TopoDS::Face(F.Oriented(TopAbs_FORWARD)); for (exp.Init(FForward,TopAbs_EDGE); exp.More(); exp.Next()) { const TopoDS_Edge& E = TopoDS::Edge( exp.Current() ); myAsDes->Add(FForward,E); if (DoneEM.Add(E)) { TopoDS_Iterator itV(E); for (; itV.More(); itV.Next()) { const TopoDS_Vertex& V = TopoDS::Vertex( itV.Value()); myAsDes->Add(E, myInter3d.ReplaceSameDomainV( V, E )); } } } } // intersect edges that are descendants of a face in myAsDes TopTools_MapOfShape& Modif = myInter3d.TouchedFaces(); for ( it.Initialize(Modif); it.More(); it.Next()) { const TopoDS_Face& F = TopoDS::Face(it.Key()); Partition_Inter2d::CompletPart2d (myAsDes, F, myInter3d.NewEdges()); } // now myAsDes contains also new vertices made at edge intersection as // descendant of edges both new and old myDoneStep = TopAbs_VERTEX; #ifdef PART_PERF MESSAGE("+++ CompletPart2d()"); aCron.Show( cout ); aCron.Reset(); aCron.Start(); #endif } // if (myDoneStep > TopAbs_VERTEX) if (Limit == TopAbs_VERTEX) { // add new vertices to myShape for ( it.Initialize( myInter3d.NewEdges() ); it.More(); it.Next()) { if (! myAsDes->HasDescendant( it.Key() )) continue; itl.Initialize( myAsDes->Descendant( it.Key() )); for (; itl.More(); itl.Next()) myBuilder.Add ( myShape, itl.Value() ); } return; } if (myDoneStep > TopAbs_EDGE) { //----------------------------------------------- //----------------------------------------------- // ------- Reconstruction of all the edges.------ //----------------------------------------------- //----------------------------------------------- // ============== // cut new edges // ============== TopTools_ListOfShape LSE; // all edge splits for ( it.Initialize(myInter3d.NewEdges()); it.More(); it.Next()) { TopoDS_Vertex V1,V2; TopoDS_Edge EE = TopoDS::Edge(it.Key()); TopTools_ListOfShape aListV, aListF; aListV = myAsDes->Descendant(EE); // intersection vertices aListF = myAsDes->Ascendant(EE); // intersected faces if (aListV.IsEmpty()) continue; // new edge does not intersect any other edge // Add end vertices to new edges only if // one face is Tool and the other is Shape Standard_Boolean isTool1 = ! myMapFaces.Contains( aListF.First() ); Standard_Boolean isTool2 = ! myMapFaces.Contains( aListF.Last() ); if (isTool1 || isTool2) { TopExp::Vertices(EE,V1,V2); Standard_Real Tol = Max (BRep_Tool::Tolerance( V1 ), BRep_Tool::Tolerance( V2 )); gp_Pnt P1 = BRep_Tool::Pnt(V1); gp_Pnt P2 = BRep_Tool::Pnt(V2); Standard_Boolean AddV1 = Standard_True; Standard_Boolean AddV2 = Standard_True; // add only if there is no intersection at end vertex for (itl.Initialize(aListV); itl.More(); itl.Next()) { const TopoDS_Vertex& Ve = TopoDS::Vertex(itl.Value()) ; Standard_Real Tol2 = Max ( Tol, BRep_Tool::Tolerance( Ve )); Tol2 *= Tol2; gp_Pnt P = BRep_Tool::Pnt(Ve); if (AddV1 && P.SquareDistance(P1) <= Tol2) AddV1 = Standard_False; if (AddV2 && P.SquareDistance(P2) <= Tol2) AddV2 = Standard_False; } if (AddV1) { aListV.Append(V1); myAsDes->Add(EE,V1); } if (AddV2) { aListV.Append(V2); myAsDes->Add(EE,V2); } } // cut new edges Standard_Integer NbV=aListV.Extent() ; if (NbV>1 || (NbV==1 && V1.IsSame(V2)) ) { TopTools_ListOfShape LNE; MakeEdges (EE,aListV, LNE); myImagesEdges.Bind(EE,LNE); LSE.Append( LNE ); } } // ============== // cut old edges // ============== for ( it.Initialize(myMapFaces); it.More(); it.Next()) { for (exp.Init( it.Key(), TopAbs_EDGE); exp.More(); exp.Next()) { const TopoDS_Edge& EE = TopoDS::Edge( exp.Current() ); if ( myImagesEdges.HasImage( EE )) continue; TopTools_ListOfShape LNE; const TopTools_ListOfShape& aListVV = myAsDes->Descendant(EE); MakeEdges (EE, aListVV, LNE); myImagesEdges.Bind(EE,LNE); LSE.Append( LNE ); } } #ifdef PART_PERF MESSAGE("+++ Cut Edges"); aCron.Show( cout ); aCron.Reset(); aCron.Start(); #endif // process same domain section edges MergeEqualEdges( LSE ); myDoneStep = TopAbs_EDGE; #ifdef PART_PERF MESSAGE("+++ MergeEqualEdges()"); aCron.Show( cout ); aCron.Reset(); aCron.Start(); #endif } // if (myDoneStep > TopAbs_EDGE) if (Limit == TopAbs_EDGE) { // add splits of old edges TopTools_ListIteratorOfListOfShape itNE; for (itl.Initialize( myListShapes );itl.More();itl.Next()) { if (myMapTools.Contains( itl.Value() )) continue; // skip tool faces for ( exp.Init( itl.Value(), TopAbs_EDGE ); exp.More(); exp.Next()) { itNE.Initialize( myImagesEdges.Image( exp.Current() )); for ( ; itNE.More(); itNE.Next()) myBuilder.Add ( myShape, itNE.Value() ); } } // add splits of new edges for ( it.Initialize( myInter3d.NewEdges() ); it.More(); it.Next()) { itNE.Initialize( myImagesEdges.Image( it.Key() )); for (; itNE.More(); itNE.Next()) myBuilder.Add ( myShape, itNE.Value() ); } return; } //----------------------------------------------- // split faces //----------------------------------------------- if (myDoneStep > TopAbs_FACE) { for (itl.Initialize(myListShapes);itl.More();itl.Next()) { TopoDS_Shape FacesComp = MakeFaces ( itl.Value()); // there is a cunning here: myImagesFaces keeps faces made by Loop2d // but some of them may be replaced with splits of same domain face // and myImageShape keeps ultimate result myImageShape.Bind( itl.Value(), FacesComp ); } myDoneStep = TopAbs_FACE; #ifdef PART_PERF MESSAGE("+++ MakeFaces()"); aCron.Show( cout ); aCron.Reset(); aCron.Start(); #endif } if (Limit == TopAbs_WIRE || Limit == TopAbs_FACE) { for (itl.Initialize(myListShapes);itl.More();itl.Next()) { if ( myMapTools.Contains( itl.Value() )) continue; // no result needed for a tool face const TopoDS_Shape& FacesComp = myImageShape.Image( itl.Value() ).First(); for ( exp.Init( FacesComp, Limit); exp.More(); exp.Next()) myBuilder.Add ( myShape, exp.Current()); } return; } //----------------------------------------------- // split and add solids and shells //----------------------------------------------- Standard_Boolean makeSolids = (Limit == TopAbs_SHAPE || Limit < TopAbs_SHELL); for (itl.Initialize(myListShapes);itl.More();itl.Next()) { const TopoDS_Shape & S = itl.Value(); if (S.ShapeType() > TopAbs_SHELL) continue; TopTools_ListOfShape NSL; // new shape list MakeShells (S , NSL); if (makeSolids && S.ShapeType() == TopAbs_SOLID ) MakeSolids( S, NSL ); // store new shells or solids TopTools_ListIteratorOfListOfShape itNSL (NSL); for ( ; itNSL.More(); itNSL.Next()) myBuilder.Add (myShape, itNSL.Value()); } #ifdef PART_PERF MESSAGE("+++ MakeShells()"); aCron.Show( cout ); #endif //----------------------------------------------- // add split faces //----------------------------------------------- for (itl.Initialize(myListShapes);itl.More();itl.Next()) { const TopoDS_Shape & S = itl.Value(); if (S.ShapeType() != TopAbs_FACE || myMapTools.Contains( S )) continue; TopoDS_Iterator itS( myImageShape.Image(S).First() ); for (; itS.More(); itS.Next()) if (! myAddedFacesMap.Contains( itS.Value() )) myBuilder.Add (myShape, itS.Value()); } myDoneStep = makeSolids ? TopAbs_SOLID : TopAbs_SHELL; } //======================================================================= //function : MakeSolids //purpose : make solids out of Shells //======================================================================= void Partition_Spliter::MakeSolids(const TopoDS_Shape & theSolid, TopTools_ListOfShape & theShellList) { // for a solid wrapping other shells or solids without intersection, // it is necessary to find shells making holes in it TopTools_ListOfShape aNewSolids; // result TopTools_ListOfShape aHoleShells; TopoDS_Shape anInfinitePointShape; Standard_Boolean isWrapping = myWrappingSolid.Contains( theSolid ); if (!isWrapping && !theShellList.IsEmpty()) { // check if theSolid initially has internal shells TopoDS_Iterator aShellExp (theSolid); aShellExp.Next(); isWrapping = aShellExp.More(); } TopTools_ListIteratorOfListOfShape aShellIt(theShellList); for ( ; aShellIt.More(); aShellIt.Next()) { const TopoDS_Shape & aShell = aShellIt.Value(); // check if a shell is a hole if (isWrapping && IsInside (anInfinitePointShape, aShell)) aHoleShells.Append( aShell ); else { // make a solid from a shell TopoDS_Solid Solid; myBuilder.MakeSolid( Solid ); myBuilder.Add (Solid, aShell); aNewSolids.Append (Solid); } } // find an outer shell most close to each hole shell TopTools_DataMapOfShapeShape aInOutMap; for (aShellIt.Initialize( aHoleShells ); aShellIt.More(); aShellIt.Next()) { const TopoDS_Shape & aHole = aShellIt.Value(); TopTools_ListIteratorOfListOfShape aSolisIt (aNewSolids); for ( ; aSolisIt.More(); aSolisIt.Next()) { const TopoDS_Shape & aSolid = aSolisIt.Value(); if (! IsInside( aHole, aSolid )) continue; if ( aInOutMap.IsBound (aHole)) { const TopoDS_Shape & aSolid2 = aInOutMap( aHole ); if ( IsInside( aSolid, aSolid2 )) { aInOutMap.UnBind( aHole ); aInOutMap.Bind ( aHole, aSolid ); } } else aInOutMap.Bind ( aHole, aSolid ); } // add aHole to a solid if (aInOutMap.IsBound( aHole )) myBuilder.Add ( aInOutMap( aHole ), aHole ); } theShellList.Clear(); theShellList.Append( aNewSolids ); } //======================================================================= //function : FindFacesInside //purpose : return compound of faces of other shapes that are // inside . // is an object shape. // makes avoid faces that do not form a // closed shell // makes return already added faces //======================================================================= TopoDS_Shape Partition_Spliter::FindFacesInside(const TopoDS_Shape& theShape, const Standard_Boolean CheckClosed, const Standard_Boolean All) { // ================================================ // check if internal faces have been already found // ================================================ TopExp_Explorer expl; if (myInternalFaces.IsBound( theShape )) { TopoDS_Shape aIntFComp = myInternalFaces.Find ( theShape ); TopoDS_Shape aIntRemFComp = myIntNotClFaces.Find ( theShape ); expl.Init( aIntRemFComp, TopAbs_FACE); if (CheckClosed || !expl.More()) return aIntFComp; TopoDS_Compound C; myBuilder.MakeCompound( C ); // add removed faces for (; expl.More(); expl.Next()) myBuilder.Add( C, expl.Current() ); // add good internal faces for (expl.Init( aIntFComp, TopAbs_FACE); expl.More(); expl.Next()) myBuilder.Add( C, expl.Current() ); return C; } // =================================== // get data for internal faces search // =================================== // compound of split faces of theShape const TopoDS_Shape& CSF = myImageShape.Image(theShape).First(); TopTools_MapOfShape MSE, MFP; TopTools_DataMapOfShapeListOfShape DMSEFP; TopTools_MapIteratorOfMapOfShape itm; TopTools_ListOfShape EmptyL; // MSE filling: map of new section edges of CSF for (expl.Init(CSF,TopAbs_EDGE); expl.More(); expl.Next()) { const TopoDS_Shape & resE = expl.Current() ; if (myNewSection.Contains( resE )) // only new edges MSE.Add(resE); } // DMEF: map edge of CSF - faces of CSF TopTools_IndexedDataMapOfShapeListOfShape DMEF; TopExp::MapShapesAndAncestors(CSF, TopAbs_EDGE, TopAbs_FACE, DMEF); // Fill // 1. MFP - a map of faces to process: map of resulting faces except // those of theShape; we`ll add to C those of them which are inside CSF // 2. DMSEFP - edge of MSE => faces of MFP TopTools_ListIteratorOfListOfShape itl; for (itl.Initialize(myListShapes);itl.More();itl.Next()) { const TopoDS_Shape& aShape = itl.Value(); if ( theShape.IsSame( aShape )) continue; // fill maps // iterate on split faces of aShape TopoDS_Iterator itF ( myImageShape.Image(aShape).First() ); for ( ; itF.More(); itF.Next()) { const TopoDS_Shape& sf = itF.Value(); MFP.Add(sf); // iterate on edges of split faces of aShape, // add to DMSEFP edges that are new for (expl.Init( sf, TopAbs_EDGE ); expl.More(); expl.Next()) { TopoDS_Shape se = expl.Current(); if ( MSE.Contains(se)) {// section edge if (!DMSEFP.IsBound(se)) DMSEFP.Bind(se,EmptyL); DMSEFP(se).Append(sf); } } } } // add tool faces having section edges on faces of theShape to MFP and DMSEFP; // such tool faces need not to be reconstructed and so they are not in myListShapes for (itm.Initialize(myMapTools); itm.More(); itm.Next()) { const TopoDS_Shape & aToolFace = itm.Key(); if (myMapFaces.Contains( aToolFace )) continue; MFP.Add(aToolFace); for (expl.Init( aToolFace, TopAbs_EDGE ); expl.More(); expl.Next()) { TopoDS_Shape se = expl.Current(); if ( MSE.Contains( se )) {// section edge if (!DMSEFP.IsBound( se )) DMSEFP.Bind( se, EmptyL ); DMSEFP( se ).Append( aToolFace ); } } } // =========================== // find faces inside theShape // =========================== Standard_Boolean skipAlreadyAdded = Standard_False; Standard_Boolean GoodOri, inside; Standard_Real dot; TopTools_ListOfShape KeepFaces; TopTools_DataMapIteratorOfDataMapOfShapeListOfShape Mapit; // iterate on section edges, check faces of other shapes // sharing section edges and put internal faces to KeepFaces for (Mapit.Initialize(DMSEFP); Mapit.More() ; Mapit.Next() ) { // a new edge of theShape const TopoDS_Edge& E = TopoDS::Edge (Mapit.Key()); // an original edge of which E is a split const TopoDS_Edge& OrigE = TopoDS::Edge ( myImagesEdges.Root( E )); // does OrigE itself splits a face Standard_Boolean isSectionE = myInter3d.IsSectionEdge ( OrigE ); // split faces of other shapes sharing E TopTools_ListOfShape& LSF = DMSEFP.ChangeFind(E); itl.Initialize( LSF ); while (itl.More()) { // a split faces of other shape TopoDS_Face aFace1 = TopoDS::Face(itl.Value()); // remove aFace1 form DMSEFP and MFP LSF.Remove( itl ); // == itl.Next(); if (!MFP.Remove( aFace1 )) continue; // was not is MFP ( i.e already checked) // check if aFace1 was already added to 2 shells if (!All && myAddedFacesMap.Contains( aFace1 ) && myAddedFacesMap.Contains( aFace1.Reversed() )) { skipAlreadyAdded = Standard_True; continue; } // find another face which originates from the same face as aFace1: // usually aFace2 is internal if aFace1 is not and vice versa TopoDS_Shape anOrigFace = aFace1; if (myImagesFaces.IsImage(aFace1)) anOrigFace = myImagesFaces.Root(aFace1); TopoDS_Shape aFace2; if ( !isSectionE ) { while (itl.More()) { aFace2 = itl.Value(); if (!MFP.Contains( aFace2 )) { LSF.Remove( itl ); continue; } if (anOrigFace.IsSame( myImagesFaces.Root( aFace2 ))) break; itl.Next(); } if (itl.More()) { // aFace2 found, remove it from maps LSF.Remove( itl ); MFP.Remove(aFace2); } else aFace2.Nullify(); itl.Initialize( LSF ); } // check that anOrigFace is not same domain with CSF faces it intersects const TopTools_ListOfShape& FL = DMEF.FindFromKey(E); //faces of CSF sharing E const TopoDS_Shape& origF1 = myImagesFaces.Root(FL.First()); const TopoDS_Shape& origF2 = myImagesFaces.Root(FL.Last()); Standard_Boolean sameDom1 = anOrigFace.IsSame( origF1 ); Standard_Boolean sameDom2 = anOrigFace.IsSame( origF2 ); if (!(sameDom1 || sameDom2) && myInter3d.HasSameDomainF( anOrigFace )) { sameDom1 = myInter3d.IsSameDomainF( anOrigFace, origF1); if (origF1 == origF2) sameDom2 = sameDom1; else myInter3d.IsSameDomainF( anOrigFace, origF2); } if (sameDom1 && sameDom2) continue; if ((sameDom1 || sameDom2)) { inside = Partition_Loop3d::IsInside (E, TopoDS::Face(FL.First()), TopoDS::Face(FL.Last()), 1, dot, GoodOri); if (inside || (dot + Precision::Angular() >= 1.0)) continue; // E is convex between origF1 and origF2 or they are tangent } // keep one of found faces //face of CSF sharing E const TopoDS_Shape& aShapeFace = sameDom1 ? FL.Last() : FL.First(); // analyse aFace1 state inside = Partition_Loop3d::IsInside (E, TopoDS::Face(aShapeFace), aFace1, 1, dot, GoodOri); if (inside && isSectionE) { // aFace1 must be tested with both adjacent faces of CSF const TopoDS_Shape& aShapeFace2 = sameDom1 ? FL.First() : FL.Last(); if (aShapeFace2 != aShapeFace) inside = Partition_Loop3d::IsInside (E, TopoDS::Face(aShapeFace2), aFace1, 1, dot, GoodOri); } // store internal face if (inside) KeepFaces.Append(aFace1); else if (!aFace2.IsNull()) { if (dot + Precision::Angular() >= 1.0) { // aFace2 state is not clear, it will be analysed alone, // put it back to the maps MFP.Add( aFace2 ); LSF.Append( aFace2 ); } else KeepFaces.Append(aFace2); } } } // =================================================== // add not distributed faces connected with KeepFaces // =================================================== // ultimate list of internal faces TopTools_ListOfShape KeptFaces; // add to MFP not split tool faces as well, they may be connected with // tool faces interfering with theShape for ( itm.Initialize(myMapTools); itm.More(); itm.Next() ) { const TopoDS_Shape& aToolFace = itm.Key(); if (!myImageShape.HasImage(aToolFace)) MFP.Add (aToolFace); } if (MFP.IsEmpty()) KeptFaces.Append (KeepFaces); while (!KeepFaces.IsEmpty()) { // KeepEdges : map of edges of faces kept last time TopTools_IndexedMapOfShape KeepEdges; for ( itl.Initialize(KeepFaces); itl.More(); itl.Next() ) { TopExp::MapShapes( itl.Value(), TopAbs_EDGE, KeepEdges); KeptFaces.Append( itl.Value() ); } KeepFaces.Clear(); // keep faces connected with already kept faces by KeepEdges for ( itm.Initialize(MFP); itm.More(); itm.Next() ) { const TopoDS_Shape& FP = itm.Key(); for (expl.Init(FP,TopAbs_EDGE); expl.More(); expl.Next()) { const TopoDS_Shape& se = expl.Current(); if (!MSE.Contains(se) && KeepEdges.Contains(se) ) { KeepFaces.Append(FP); MFP.Remove(FP); break; } } } } // =============================================================== // here MFP contains faces outer of theShape and those of shapes // which do not interfere with theShape at all and between which // there may be those wrapped by theShape and whose faces may be // needed to be returned as well // =============================================================== Standard_Boolean isSolid = (theShape.ShapeType() == TopAbs_SOLID); if (All || isSolid) // All is for sub-result removal { // loop on not used faces; checked faces will be removed from MFP // during the loop for ( itm.Initialize( MFP ); itm.More(); itm.Next() ) { const TopoDS_Shape & aFace = itm.Key(); // a shape which aFace originates from TopoDS_Shape anOrigShape = GetOriginalShape( aFace ); // find out if all split faces of anOrigShape are not in MFP // and by the way remove them from MFP Standard_Boolean isAllOut = Standard_True; TopoDS_Shape aSplitFaces = anOrigShape; if (myImageShape.HasImage(anOrigShape)) aSplitFaces = myImageShape.Image(anOrigShape).First(); TopTools_ListOfShape aSplitFaceL; // faces candidate to be kept for (expl.Init( aSplitFaces, TopAbs_FACE ); expl.More(); expl.Next()) { const TopoDS_Shape & aSpFace = expl.Current(); // a tool face which became object has image but the whole tool shape has not if (myImageShape.HasImage( aSpFace )) { TopExp_Explorer exF (myImageShape.Image( aSpFace ).First(), TopAbs_FACE ); for ( ; exF.More(); exF.Next() ) { aSplitFaceL.Append( exF.Current() ); if ( ! MFP.Remove( exF.Current() ) && isAllOut ) // a shared face might be removed from MFP during a prev loop isAllOut = mySharedFaces.Contains( exF.Current() ); } } else { aSplitFaceL.Append( aSpFace ); if ( ! MFP.Remove( aSpFace ) && isAllOut) // a shared face might be removed from MFP during a prev loop isAllOut = mySharedFaces.Contains( aSpFace ); } } itm.Initialize( MFP ); // iterate remaining faces if ( !isAllOut ) continue; // classify anOrigShape against theShape if (IsInside (anOrigShape, theShape)) { if (isSolid && myClosedShapes.Contains( anOrigShape )) // to make a special care at solid reconstruction myWrappingSolid.Add ( theShape ); // keep faces of an internal shape anOrigShape KeptFaces.Append( aSplitFaceL ); } } } // ==================================================== // check if kept faces form a shell without free edges // ==================================================== DMEF.Clear(); // edge - kept faces MFP.Clear(); // reuse it for wrong faces if (CheckClosed) { for (itl.Initialize(KeptFaces); itl.More(); itl.Next() ) TopExp::MapShapesAndAncestors(itl.Value(), TopAbs_EDGE, TopAbs_FACE, DMEF); Standard_Integer i, nb = DMEF.Extent(); Standard_Boolean isClosed = Standard_False; while (!isClosed) { isClosed = Standard_True; for (i=1; isClosed && i<=nb; ++i) { const TopoDS_Shape& E = DMEF.FindKey( i ); if (! BRep_Tool::Degenerated( TopoDS::Edge( E )) && ! MSE.Contains( E )) isClosed = ( DMEF(i).Extent() != 1 ); } if (!isClosed) { const TopoDS_Shape& F = DMEF.FindFromIndex( i-1 ).First(); // bad face MFP.Add( F ); // remove bad face from DMEF for (expl.Init( F, TopAbs_EDGE); expl.More(); expl.Next()) { const TopoDS_Shape& E = expl.Current(); TopTools_ListOfShape& FL = DMEF.ChangeFromKey( E ); for (itl.Initialize( FL ); itl.More(); itl.Next() ) { if ( F.IsSame( itl.Value() )) { FL.Remove( itl ); break; } } } } } } // ============== // make a result // ============== TopoDS_Compound C; // compound of removed internal faces TopoDS_Compound CNotCl; myBuilder.MakeCompound(C); myBuilder.MakeCompound(CNotCl); // add to compounds for (itl.Initialize(KeptFaces); itl.More(); itl.Next() ) { TopoDS_Shape & aIntFace = itl.Value(); if (! MFP.Contains( aIntFace )) myBuilder.Add( C, aIntFace); else myBuilder.Add( CNotCl, aIntFace); } if (!skipAlreadyAdded && CheckClosed) { myInternalFaces.Bind( theShape, C ); myIntNotClFaces.Bind( theShape, CNotCl ); } return C; } //======================================================================= //function : MakeShell //purpose : split S into compound of shells //======================================================================= void Partition_Spliter::MakeShells(const TopoDS_Shape& S, TopTools_ListOfShape& NS) { Partition_Loop3d ShellMaker; // get compound of split faces of S const TopoDS_Shape& FacesComp = myImageShape.Image(S).First(); ShellMaker.AddConstFaces( FacesComp ); // add split faces inside S if (myClosedShapes.Contains( S )) { TopoDS_Shape InternalFacesComp = FindFacesInside(S, Standard_True); ShellMaker.AddSectionFaces( InternalFacesComp ); } NS = ShellMaker.MakeShells( myAddedFacesMap ); // Add faces added to new shell to myAddedFacesMap: // avoid rebuilding twice commont part of 2 solids. TopTools_ListIteratorOfListOfShape itS(NS); while ( itS.More()) { TopExp_Explorer expF (itS.Value(), TopAbs_FACE); for (; expF.More(); expF.Next()) myAddedFacesMap.Add (expF.Current()); itS.Next(); } } //======================================================================= //function : findEqual //purpose : compare edges of EL1 against edges of EL2, // Result is in EMM binding EL1 edges to list of equal edges. // Edges are considered equall only if they have same vertices. // ==True makes consider same edges as equal // Put in all equal edges //======================================================================= static void findEqual (const TopTools_ListOfShape& EL1, const TopTools_ListOfShape& EL2, const Standard_Boolean addSame, TopTools_DataMapOfShapeListOfShape& EEM, TopTools_MapOfShape& AllEqMap) { // map vertices to edges for EL2 TopTools_DataMapOfShapeListOfShape VEM; TopTools_ListIteratorOfListOfShape itE1, itE2(EL2); TopoDS_Iterator itV; TopTools_ListOfShape emptyL; for (; itE2.More(); itE2.Next()) { for (itV.Initialize( itE2.Value() ); itV.More(); itV.Next()) { const TopoDS_Shape& V = itV.Value(); if (! VEM.IsBound( V ) ) VEM.Bind( V, emptyL); VEM( V ).Append( itE2.Value()); } } gp_Vec D1, D2; gp_Pnt P; Standard_Real f,l,u,tol; Handle(Geom_Curve) C1, C2; Extrema_ExtPC Extrema; TopoDS_Vertex V1, V2, V3, V4; AllEqMap.Clear(); for (itE1.Initialize(EL1); itE1.More(); itE1.Next()) { const TopoDS_Edge& E1 = TopoDS::Edge( itE1.Value()); if (BRep_Tool::Degenerated( E1 ) || AllEqMap.Contains (E1)) continue; TopExp::Vertices( E1, V1, V2 ); if (VEM.IsBound(V1)) itE2.Initialize( VEM(V1) ); for (; itE2.More(); itE2.Next()) { const TopoDS_Edge& E2 = TopoDS::Edge( itE2.Value()); if (BRep_Tool::Degenerated( E2 ) || AllEqMap.Contains (E2)) continue; if (E1.IsSame(E2)) { if (!addSame) continue; } else { TopExp::Vertices( E2, V3, V4); if (!V2.IsSame(V4) && !V2.IsSame(V3)) continue; // E1 and E2 have same vertices // check D1 at end points. C2 = BRep_Tool::Curve( E2, f,l); C1 = BRep_Tool::Curve( E1, f,l); u = BRep_Tool::Parameter(V1,E1); C1->D1(u, P, D1); u = BRep_Tool::Parameter(V1.IsSame(V3) ? V3 : V4, E2); C2->D1(u, P, D2); D1.Normalize(); D2.Normalize(); if (Abs(D1*D2) + Precision::Angular() < 1.0) continue; if (! V1.IsSame(V2)) { u = BRep_Tool::Parameter(V2,E1); C1->D1(u, P, D1); u = BRep_Tool::Parameter(V2.IsSame(V3) ? V3 : V4, E2); C2->D1(u, P, D2); D1.Normalize(); D2.Normalize(); if (Abs(D1*D2) + Precision::Angular() < 1.0) continue; } // check distance at a couple of internal points tol = Max(BRep_Tool::Tolerance(E1), BRep_Tool::Tolerance(E2)); GeomAdaptor_Curve AC1(C1); Extrema.Initialize(AC1,f,l); Standard_Boolean ok = Standard_True, hasMin = Standard_False; BRep_Tool::Range( E2, f, l); Standard_Integer i=1, nbi=3; for (; iValue( f+(l-f)*i/nbi )); Standard_Integer j=1, nbj=Extrema.NbExt(); for (; j<=nbj && ok; ++j) { if (Extrema.IsMin(j)) { hasMin = Standard_True; ok = Extrema.Value(j) <= tol; } } } if ( !hasMin || !ok) continue; } // bind E2 to E1 in EEM if (!EEM.IsBound(E1)) { EEM.Bind (E1, emptyL); AllEqMap.Add (E1); } EEM(E1).Append(E2); AllEqMap.Add (E2); } } } //======================================================================= //function : MakeFaces //purpose : split faces of S, return compound of new faces //======================================================================= TopoDS_Shape Partition_Spliter::MakeFaces (const TopoDS_Shape& S) { TopoDS_Compound C; myBuilder.MakeCompound(C); TopTools_ListIteratorOfListOfShape itl, itNE; TopExp_Explorer exp(S,TopAbs_FACE); for (; exp.More(); exp.Next()) { const TopoDS_Face& F = TopoDS::Face(exp.Current()); TopTools_ListOfShape LNF; if (myImagesFaces.HasImage( F )) { myImagesFaces.LastImage( F, LNF ); TopAbs_Orientation oriF = F.Orientation(); for ( itl.Initialize( LNF ); itl.More(); itl.Next()) itl.Value().Orientation( oriF ); } else { Partition_Loop2d loops; loops.Init(F); TopTools_IndexedMapOfShape EM; TopExp::MapShapes( F, TopAbs_EDGE, EM); TopTools_MapOfShape AddedEqualM, EqualSeamM; Standard_Boolean needRebuild = Standard_False; // add splits to loops // LE: old edges + new not splitted edges const TopTools_ListOfShape& LE = myAsDes->Descendant(F); for (itl.Initialize(LE); itl.More(); itl.Next()) { const TopoDS_Edge& E = TopoDS::Edge( itl.Value() ); Standard_Boolean isSectionE = myInter3d.IsSectionEdge(E); Standard_Boolean isNewE = !EM.Contains( E ); // LSE: list of split edges TopTools_ListOfShape LSE; myImagesEdges.LastImage(E,LSE); // splits of E or E itself for (itNE.Initialize(LSE); itNE.More(); itNE.Next()) { TopoDS_Edge NE = TopoDS::Edge( itNE.Value() ); Standard_Boolean isSameE = NE.IsSame ( E ); if ( isNewE || isSectionE || !isSameE) { if (AddedEqualM.Contains( NE )) { // a seam must be twice in a loop if (!BRep_Tool::IsClosed( E, F ) || !EqualSeamM.Add( NE )) continue; } if (isNewE) { if (isSectionE) { if ( ! myInter3d.IsSplitOn( NE, E, F) ) continue; } else { TopoDS_Vertex V1,V2; TopExp::Vertices(NE,V1,V2); const TopTools_ListOfShape& EL1 = myAsDes->Ascendant(V1); const TopTools_ListOfShape& EL2 = myAsDes->Ascendant(V2); if ( EL1.Extent() < 2 && EL2.Extent() < 2 ) continue; } } else { NE.Orientation( E.Orientation()); if (!isSameE) { // orient NE because it may be a split of other edge Standard_Real f,l,u; Handle(Geom_Curve) C3d = BRep_Tool::Curve( E,f,l ); Handle(Geom_Curve) NC3d = BRep_Tool::Curve( NE,f,l); if ( C3d != NC3d) { gp_Vec D1, ND1; gp_Pnt P; TopoDS_Vertex V = TopExp::FirstVertex(NE); u = BRep_Tool::Parameter(V,NE); NC3d->D1 (u, P, ND1); u = BRep_Tool::Parameter(V,E); C3d ->D1 (u, P, D1); if (ND1.Dot(D1) < 0) NE.Reverse(); } } } if (myEqualEdges.Contains( NE )) AddedEqualM.Add( NE ); needRebuild = Standard_True; } if (isNewE || isSectionE) myNewSection.Add( NE ); if (isNewE) loops.AddSectionEdge(NE); else loops.AddConstEdge(NE); } } //------------------- // Build the faces. //------------------- if (needRebuild) { loops.Perform(); loops.WiresToFaces(myImagesEdges); LNF = loops.NewFaces(); myImagesFaces.Bind(F,LNF); // replace the result faces that have already been built // during same domain faces reconstruction done earlier if (myInter3d.HasSameDomainF( F )) { // build map edge to same domain faces: EFM TopTools_IndexedDataMapOfShapeListOfShape EFM; TopTools_MapOfShape SDFM; // avoid doubling itl.Initialize( myInter3d.SameDomain( F )); for (; itl.More(); itl.Next()) { if ( !myImagesFaces.HasImage( itl.Value() )) continue; // loop on splits of a SD face TopTools_ListIteratorOfListOfShape itNF; itNF.Initialize (myImagesFaces.Image( itl.Value() )); for ( ; itNF.More(); itNF.Next()) { TopoDS_Shape SDF = itNF.Value(); if (myImagesFaces.HasImage( SDF )) // already replaced SDF = myImagesFaces.Image( SDF ).First(); if (SDFM.Add (SDF)) TopExp::MapShapesAndAncestors(SDF, TopAbs_EDGE, TopAbs_FACE, EFM); } } // do replace faces in the LNF TopTools_ListOfShape LOF; if ( !EFM.IsEmpty() ) itl.Initialize( LNF ); while (itl.More()) { const TopoDS_Shape& NF = itl.Value(); TopExp_Explorer expE ( NF, TopAbs_EDGE ); const TopoDS_Edge& E = TopoDS::Edge (expE.Current()); if (EFM.Contains( E )) { const TopTools_ListOfShape& SDFL = EFM.FindFromKey( E ); TopoDS_Shape SDF = SDFL.First(); Standard_Boolean GoodOri; Standard_Real dot; Partition_Loop3d::IsInside (E, TopoDS::Face(NF), TopoDS::Face(SDF), 1, dot, GoodOri); if (dot < 0) { // NF and SDF are on different side of E if (SDFL.Extent() == 1) { itl.Next(); continue; } else SDF = SDFL.Last(); // next face must be on the same side } gp_Vec V1 = Partition_Loop3d::Normal( E, TopoDS::Face( NF )); gp_Vec V2 = Partition_Loop3d::Normal( E, TopoDS::Face( SDF )); if (V1*V2 < 0) SDF.Reverse(); if (!myImagesFaces.HasImage( NF )) myImagesFaces.Bind( NF, SDF ); // mySharedFaces is used in FindFacesInside() mySharedFaces.Add( SDF ); LOF.Prepend ( SDF ); LNF.Remove (itl); } else itl.Next(); } LNF.Append (LOF); } } // if (needRebuild) else { LNF.Append( F ); myImagesFaces.Bind(F,LNF); } } // if (myImagesFaces.HasImage( F )) // fill the resulting compound for (itl.Initialize(LNF); itl.More(); itl.Next()) myBuilder.Add ( C, itl.Value()); } // loop on faces of S return C; } //======================================================================= //function : Tri //purpose : //======================================================================= static void Tri(const TopoDS_Edge& E, TopTools_SequenceOfShape& Seq, const Partition_Inter3d & theInter3d) { Standard_Boolean Invert = Standard_True; Standard_Real U1,U2; TopoDS_Vertex V1,V2; while (Invert) { Invert = Standard_False; for ( Standard_Integer i = 1; i < Seq.Length(); i++) { V1 = TopoDS::Vertex(Seq.Value(i)); V2 = TopoDS::Vertex(Seq.Value(i+1)); V1.Orientation(TopAbs_INTERNAL); V2.Orientation(TopAbs_INTERNAL); U1 = BRep_Tool::Parameter(V1,E); U2 = BRep_Tool::Parameter(V2,E); if (IsEqual(U1,U2)) { if (theInter3d.ReplaceSameDomainV( V1, E ).IsSame( V1 )) Seq.Remove(i+1); // remove V2 else Seq.Remove(i); i--; continue; } if (U2 < U1) { Seq.Exchange(i,i+1); Invert = Standard_True; } } } } //======================================================================= //function : MakeEdges //purpose : cut E by vertices VOnE, return list of new edges NE //======================================================================= void Partition_Spliter::MakeEdges (const TopoDS_Edge& E, const TopTools_ListOfShape& VOnE, TopTools_ListOfShape& NE ) const { TopoDS_Edge WE = E; WE.Orientation(TopAbs_FORWARD); Standard_Real U1,U2, f, l; TopoDS_Vertex V1,V2,VF,VL; BRep_Tool::Range(WE,f,l); TopExp::Vertices(WE,VF,VL); if (VOnE.Extent() < 3) { // do not rebuild not cut edge if (( VF.IsSame( VOnE.First() ) && VL.IsSame( VOnE.Last() )) || VL.IsSame( VOnE.First() ) && VF.IsSame( VOnE.Last() ) ) { NE.Append( E ); return; } } TopTools_SequenceOfShape SV; TopTools_ListIteratorOfListOfShape itv(VOnE); TopTools_MapOfOrientedShape VM( VOnE.Extent() ); for (; itv.More(); itv.Next()) if ( VM.Add( itv.Value() )) SV.Append(itv.Value()); Tri( WE, SV, myInter3d ); if (SV.Length() < 3) { // do not rebuild not cut edge if (( VF.IsSame( SV.First() ) && VL.IsSame( SV.Last() )) || VL.IsSame( SV.First() ) && VF.IsSame( SV.Last() ) ) { NE.Append( E ); return; } } Standard_Integer iVer, NbVer = SV.Length(); //---------------------------------------------------------------- // Construction of the new edges . //---------------------------------------------------------------- if (VF.IsSame(VL)) { // closed edge if (NbVer==1) SV.Append( SV.First() ); else if (!SV.First().IsSame(SV.Last())) { Standard_Boolean isFirst=0; Standard_Real minDU = 1.e10; TopoDS_Vertex endV = Partition_Inter2d::FindEndVertex(VOnE, f,l, E, isFirst,minDU); if (endV.IsSame(SV.First())) SV.Append(endV); else if (endV.IsSame(SV.Last())) SV.Prepend(endV); else MESSAGE ("END VERTEX IS IN SEQUNCE MIDDLE"); } NbVer = SV.Length(); } for (iVer=1; iVer < NbVer; iVer++) { V1 = TopoDS::Vertex(SV(iVer)); V2 = TopoDS::Vertex(SV(iVer+1)); TopoDS_Shape NewEdge = WE.EmptyCopied(); V1.Orientation(TopAbs_FORWARD); myBuilder.Add (NewEdge,V1); V2.Orientation(TopAbs_REVERSED); myBuilder.Add (NewEdge,V2); if (iVer==1) U1 = f; else { V1.Orientation(TopAbs_INTERNAL); U1=BRep_Tool::Parameter(V1,WE); } if (iVer+1 == NbVer) U2 = l; else { V2.Orientation(TopAbs_INTERNAL); U2=BRep_Tool::Parameter(V2,WE); } if (Abs(U1-U2) <= Precision::PConfusion()) { MESSAGE( "MakeEdges(), EQUAL PARAMETERS OF DIFFERENT VERTICES"); continue; } TopoDS_Edge EE=TopoDS::Edge(NewEdge); myBuilder.Range (EE,U1,U2); TopoDS_Edge NEdge = TopoDS::Edge(NewEdge); myBuilder.SameParameter(NEdge,Standard_False); Standard_Real tol = 1.0e-2; Standard_Boolean flag = BRep_Tool::SameParameter(NEdge); if (!flag) { BRepLib::SameParameter(NEdge,tol); } NE.Append(NEdge.Oriented(E.Orientation())); } } //======================================================================= //function : MergeEqualEdges //purpose : find equal edges, choose ones to keep and make // them have pcurves on all faces they are shared by //======================================================================= void Partition_Spliter::MergeEqualEdges (const TopTools_ListOfShape& LSE) { // find equal edges // map: edge - equal edges TopTools_DataMapOfShapeListOfShape EEM( LSE.Extent() ); findEqual (LSE, LSE, 0, EEM, myEqualEdges); TopTools_ListOfShape EEL; // list of equal edges TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itM (EEM); for ( ; itM.More(); itM.Next()) { EEL = itM.Value(); EEL.Append( itM.Key() ); // choose an edge to keep, section edges have priority TopoDS_Edge EKeep; TopTools_ListIteratorOfListOfShape itEE (EEL); for (; itEE.More(); itEE.Next()) { EKeep = TopoDS::Edge( itEE.Value() ); const TopoDS_Edge& EKeepOrig = TopoDS::Edge( myImagesEdges.Root( EKeep )); if (myInter3d.IsSectionEdge( EKeepOrig )) break; } // update edge images and build pcurves Standard_Real f,l, tol; for (itEE.Initialize (EEL); itEE.More(); itEE.Next()) { const TopoDS_Edge& E = TopoDS::Edge( itEE.Value() ); if ( E.IsSame( EKeep )) continue; // 1. build pcurves of the kept edge on faces where replaced edges exist const TopoDS_Edge& EReplOrig = TopoDS::Edge( myImagesEdges.Root( E )); TopTools_ListOfShape FL; FL = myAsDes->Ascendant( EReplOrig ); Standard_Integer iFace, iFirstSectionFace = FL.Extent() + 1; // add faces where the replaced edge is a section edge if (myInter3d.IsSectionEdge( EReplOrig )) { TopTools_ListIteratorOfListOfShape seIt; seIt.Initialize( myInter3d.SectionEdgeFaces ( EReplOrig )); for ( ; seIt.More(); seIt.Next()) FL.Append( seIt.Value() ); } // loop on faces TopTools_ListIteratorOfListOfShape itF (FL); for ( iFace = 1 ; itF.More(); itF.Next(), ++iFace ) { const TopoDS_Face& F = TopoDS::Face( itF.Value()); Handle(Geom2d_Curve) pc = BRep_Tool::CurveOnSurface( EKeep, F, f,l); if (pc.IsNull()) { Handle(Geom_Curve) C3d = BRep_Tool::Curve( EKeep, f, l); C3d = new Geom_TrimmedCurve( C3d, f,l); pc = TopOpeBRepTool_CurveTool::MakePCurveOnFace (F,C3d,tol); if (pc.IsNull()) { MESSAGE (" CANT BUILD PCURVE "); } myBuilder.UpdateEdge( EKeep, pc, F, tol); } if (iFace >= iFirstSectionFace || !BRep_Tool::IsClosed( EReplOrig, F )) continue; // build the second pcurve for a seam TopoDS_Vertex V = TopExp::FirstVertex( EKeep ); Standard_Real Ukeep = BRep_Tool::Parameter( V, EKeep ); Standard_Real Urepl = BRep_Tool::Parameter( V, E ); TopoDS_Edge EReplRev = E; EReplRev.Reverse(); Handle(Geom2d_Curve) pcRepl1 = BRep_Tool::CurveOnSurface( E, F, f,l); Handle(Geom2d_Curve) pcRepl2 = BRep_Tool::CurveOnSurface( EReplRev, F, f,l); gp_Pnt2d p1r, p2r, pk; p1r = pcRepl1->Value( Urepl ); p2r = pcRepl2->Value( Urepl ); pk = pc->Value( Ukeep ); // suppose that pk is equal to either p1r or p2r Standard_Boolean isUPeriod = ( Abs( p1r.X() - p2r.X() ) > Abs( p1r.Y() - p2r.Y() )); Standard_Boolean is1Equal; if (isUPeriod) is1Equal = ( Abs( p1r.X() - pk.X() ) < Abs( p2r.X() - pk.X() )); else is1Equal = ( Abs( p1r.Y() - pk.Y() ) < Abs( p2r.Y() - pk.Y() )); Handle(Geom2d_Curve) pc2 = Handle(Geom2d_Curve)::DownCast ( pc->Translated( pk, is1Equal ? p2r : p1r ) ); if (E.Orientation() == TopAbs_REVERSED) is1Equal = !is1Equal; if (is1Equal) myBuilder.UpdateEdge( EKeep, pc, pc2, F, tol); else myBuilder.UpdateEdge( EKeep, pc2, pc, F, tol); } // loop on a Faces where a replaced edge exists // 2. update edge images according to replacement if (myImagesEdges.HasImage( E )) myImagesEdges.Remove( E ); myImagesEdges.Bind( E, EKeep ); } // loop on a list of equal edges EEL } // loop on a map of equal edges EEM } //======================================================================= //function : KeepShapesInside //purpose : remove shapes that are outside of S from resul //======================================================================= void Partition_Spliter::KeepShapesInside (const TopoDS_Shape& S) { TopoDS_Iterator it; if (S.ShapeType() < TopAbs_SOLID) { // compound or compsolid for (it.Initialize( S ); it.More(); it.Next()) KeepShapesInside( it.Value()); return; } Standard_Boolean isTool = Standard_False; if (!myImageShape.HasImage( S )) { isTool = CheckTool( S ); if (!isTool) return; } // build map of internal faces TopTools_IndexedMapOfShape MIF; TopoDS_Shape IntFacesComp = FindFacesInside( S, Standard_False, Standard_True); TopExp::MapShapes( IntFacesComp, TopAbs_FACE, MIF ); TopoDS_Compound C; myBuilder.MakeCompound(C); TopAbs_ShapeEnum anInternalShapeType = TopAbs_SHAPE; if (!MIF.IsEmpty()) { // leave in the result only those shapes having a face in MIF for (it.Initialize( myShape ); it.More(); it.Next()) { const TopoDS_Shape & aResShape = it.Value(); TopExp_Explorer expResF( aResShape, TopAbs_FACE ); for (; expResF.More(); expResF.Next()) { if ( MIF.Contains( expResF.Current())) { myBuilder.Add( C, aResShape ); if (aResShape.ShapeType() < anInternalShapeType) anInternalShapeType = aResShape.ShapeType(); break; } } } } // may be S was not split by internal faces then it is missing // in myShape, add it if (!isTool && (anInternalShapeType > TopAbs_SOLID || S.ShapeType() > TopAbs_SOLID)) { TopTools_IndexedMapOfShape MSF; // map of split faces of S TopExp::MapShapes( myImageShape.Image(S).First(), TopAbs_FACE, MSF); // find a shape having all faces in MSF for (it.Initialize( myShape ); it.More(); it.Next()) { TopExp_Explorer expResF( it.Value(), TopAbs_FACE ); for (; expResF.More(); expResF.Next()) { if (! MSF.Contains( expResF.Current())) break; } if (! expResF.More()) { myBuilder.Add( C, it.Value() ); break; } } } myShape = C; } //======================================================================= //function : RemoveShapesInside //purpose : remove shapes that are inside S from resul //======================================================================= void Partition_Spliter::RemoveShapesInside (const TopoDS_Shape& S) { TopoDS_Iterator it; if (S.ShapeType() < TopAbs_SOLID) { // compound or compsolid for (it.Initialize( S ); it.More(); it.Next()) RemoveShapesInside( it.Value()); return; } Standard_Boolean isTool = Standard_False; if (!myImageShape.HasImage( S )) { isTool = CheckTool( S ); if (!isTool) return; } TopoDS_Shape IntFacesComp = FindFacesInside( S, Standard_False, Standard_True); TopTools_IndexedMapOfShape MIF; // map of internal faces TopExp::MapShapes( IntFacesComp, TopAbs_FACE, MIF); if (MIF.IsEmpty()) return; // add to MIF split faces of S if (myImageShape.HasImage(S)) TopExp::MapShapes( myImageShape.Image(S).First(), TopAbs_FACE, MIF); // leave in the result only those shapes not having all face in MIF TopoDS_Compound C; myBuilder.MakeCompound(C); // RMF : faces of removed shapes that encounter once TopTools_MapOfShape RFM; for (it.Initialize( myShape ); it.More(); it.Next()) { TopExp_Explorer expResF( it.Value(), TopAbs_FACE ); for (; expResF.More(); expResF.Next()) if (!MIF.Contains( expResF.Current())) break; if (expResF.More()) // add shape to result myBuilder.Add( C, it.Value() ); else // add faces of a removed shape to RFM for (expResF.ReInit(); expResF.More(); expResF.Next()) { const TopoDS_Shape& F = expResF.Current(); if ( ! RFM.Remove ( F )) RFM.Add( F ); } } if (!isTool) { // rebuild S, it must remain in the result Standard_Boolean isClosed = Standard_False; switch (S.ShapeType()) { case TopAbs_SOLID : isClosed = Standard_True; break; case TopAbs_SHELL: { TopTools_IndexedDataMapOfShapeListOfShape MEF; TopExp::MapShapesAndAncestors(S, TopAbs_EDGE, TopAbs_FACE, MEF); Standard_Integer i; for (i=1; isClosed && i<=MEF.Extent(); ++i) isClosed = ( MEF(i).Extent() != 1 ); break; } default: isClosed = Standard_False; } if (isClosed) { // add to a new shape external faces of removed shapes, ie those in RFM TopoDS_Shell Shell; myBuilder.MakeShell( Shell ); // exclude redundant internal face with edges encounterd only once TopTools_IndexedDataMapOfShapeListOfShape MEF; TopTools_MapIteratorOfMapOfShape itF (RFM); for ( ; itF.More(); itF.Next()) TopExp::MapShapesAndAncestors(itF.Key(), TopAbs_EDGE, TopAbs_FACE, MEF); // add only faces forming a closed shell for (itF.Reset() ; itF.More(); itF.Next()) { TopExp_Explorer expE (itF.Key(), TopAbs_EDGE); for (; expE.More(); expE.Next()) if (MEF.FindFromKey(expE.Current()).Extent() == 1) break; if (!expE.More()) myBuilder.Add( Shell, itF.Key()); } if (S.ShapeType() == TopAbs_SOLID) { TopoDS_Solid Solid; myBuilder.MakeSolid( Solid ); myBuilder.Add (Solid, Shell); myBuilder.Add (C, Solid); } else myBuilder.Add (C, Shell); } else { if (myImageShape.HasImage( S )) { for (it.Initialize( myImageShape.Image(S).First()); it.More(); it.Next()) myBuilder.Add (C, it.Value()); } } } myShape = C; } //======================================================================= //function : CheckTool //purpose : Return True if is a tool shape. Prepare tool // faces of for the search of internal faces. //======================================================================= Standard_Boolean Partition_Spliter::CheckTool(const TopoDS_Shape& S) { // suppose S has not an image Standard_Boolean isTool = Standard_False; TopoDS_Compound C; myBuilder.MakeCompound( C ); TopExp_Explorer expF( S, TopAbs_FACE); for (; expF.More(); expF.Next()) { const TopoDS_Face& F = TopoDS::Face( expF.Current() ); if (myMapTools.Contains( F )) isTool = Standard_True; else continue; if (myImagesFaces.HasImage( F )) { // F has been reconstructed TopAbs_Orientation Fori = F.Orientation(); TopTools_ListOfShape LNF; myImagesFaces.LastImage( F, LNF); TopTools_ListIteratorOfListOfShape itF (LNF); for ( ; itF.More(); itF.Next()) myBuilder.Add( C, itF.Value().Oriented(Fori) ); continue; } Standard_Boolean hasSectionE = myInter3d.HasSectionEdge( F ); Standard_Boolean hasNewE = myAsDes->HasDescendant( F ); if (!hasSectionE && !hasNewE) { // F intersects nothing myBuilder.Add( C, F ); continue; } // make an image for F TopoDS_Face NF = F; NF.Orientation(TopAbs_FORWARD); NF = TopoDS::Face( NF.EmptyCopied() ); // make a copy TopoDS_Wire NW; myBuilder.MakeWire( NW ); // add edges, as less as possible TopTools_ListOfShape NEL; TopTools_ListIteratorOfListOfShape itNE; if (hasSectionE) { // add section edges TopExp_Explorer expE; for ( ; expE.More(); expE.Next()) { if (! myImagesEdges.HasImage( expE.Current() )) continue; myImagesEdges.LastImage( expE.Current(), NEL ); for ( itNE.Initialize( NEL ); itNE.More(); itNE.Next()) myBuilder.Add ( NW, itNE.Value()); } } if (hasNewE) { // add new adges NEL = myAsDes->Descendant( F ); for ( itNE.Initialize( NEL ); itNE.More(); itNE.Next()) { TopTools_ListOfShape SEL; // splits myImagesEdges.LastImage( itNE.Value(), SEL ); TopTools_ListIteratorOfListOfShape itSE (SEL); for ( ; itSE.More(); itSE.Next()) myBuilder.Add ( NW, itSE.Value()); } } myBuilder.Add( NF, NW ); myBuilder.Add (C, NF); NF.Orientation( F.Orientation() ); // NF is most probably invalid myImagesFaces.Bind (F, NF); } if (isTool) myImageShape.Bind (S, C); return isTool; } //======================================================================= //function : IsInside //purpose : Return True if the first vertex of S1 inside S2. // If S1.IsNull(), check infinite point against S2. //======================================================================= Standard_Boolean Partition_Spliter::IsInside (const TopoDS_Shape& theS1, const TopoDS_Shape& theS2) { BRepClass3d_SolidClassifier aClassifier( theS2 ); TopExp_Explorer expl( theS1, TopAbs_VERTEX ); if (!expl.More()) aClassifier.PerformInfinitePoint( ::RealSmall()); else { const TopoDS_Vertex & aVertex = TopoDS::Vertex( expl.Current() ); aClassifier.Perform (BRep_Tool::Pnt( aVertex ), BRep_Tool::Tolerance( aVertex )); } return ( aClassifier.State() == TopAbs_IN ); } //======================================================================= //function : GetOriginalShape //purpose : Return the shape aShape originates from. aShape // should be a face or more complex result shape //======================================================================= TopoDS_Shape Partition_Spliter::GetOriginalShape(const TopoDS_Shape& theShape) const { TopoDS_Shape anOrigShape; TopExp_Explorer expl( theShape, TopAbs_FACE); if (expl.More()) { TopoDS_Shape aFace = expl.Current(); if (myImagesFaces.IsImage( aFace )) aFace = myImagesFaces.Root( aFace ); anOrigShape = myFaceShapeMap.Find( aFace ); } return anOrigShape; } //======================================================================= //function : FindToolsToReconstruct //purpose : find and store as objects tools which interfere // with solids or are inside solids without // an interference //======================================================================= void Partition_Spliter::FindToolsToReconstruct() { if (myMapTools.IsEmpty()) return; Standard_Integer nbFoundTools = 0; // build edge - face map in order to detect interference with section edges TopTools_IndexedDataMapOfShapeListOfShape EFM; TopTools_MapIteratorOfMapOfShape aMapIt; for (aMapIt.Initialize(myMapTools); aMapIt.More(); aMapIt.Next()) TopExp::MapShapesAndAncestors( aMapIt.Key(), TopAbs_EDGE, TopAbs_FACE, EFM); for (aMapIt.Initialize(myMapFaces); aMapIt.More(); aMapIt.Next()) TopExp::MapShapesAndAncestors( aMapIt.Key(), TopAbs_EDGE, TopAbs_FACE, EFM); TopTools_MapOfShape aCurrentSolids, aCheckedShapes; // faces cut by new edges TopTools_MapOfShape & aSectionFaces = myInter3d.TouchedFaces(); // keep solids interfering with each other in aCurrentSolids map // and add tool faces intersecting solids as object shapes TopTools_ListIteratorOfListOfShape itS, itF, itCF, itE; for (itS.Initialize( myListShapes ); itS.More(); itS.Next()) { TopExp_Explorer expSo (itS.Value(), TopAbs_SOLID); for (; expSo.More(); expSo.Next()) { // check if a solid has been already processed const TopoDS_Shape & aSo = expSo.Current(); if (!aCheckedShapes.Add( aSo )) continue; aCurrentSolids.Add( aSo ); // faces to check TopTools_ListOfShape aFacesToCheck; TopExp_Explorer exp( aSo, TopAbs_FACE ); for ( ; exp.More(); exp.Next()) aFacesToCheck.Append ( exp.Current()); // add other shapes interefering with a solid. // iterate faces to check while appending new ones for (itCF.Initialize (aFacesToCheck) ; itCF.More(); itCF.Next()) { const TopoDS_Shape& aCheckFace = itCF.Value(); // if (!aCheckedShapes.Add( aCheckFace )) // continue; // find faces interfering with aCheckFace TopTools_ListOfShape anIntFaces; // ** 1. faces intersecting aCheckFace with creation of new edges on it if ( myAsDes->HasDescendant( aCheckFace )) { // new edges on aCheckFace const TopTools_ListOfShape& NEL = myAsDes->Descendant( aCheckFace ); for (itE.Initialize( NEL); itE.More(); itE.Next()) { const TopoDS_Shape & aNewEdge = itE.Value(); if (!aCheckedShapes.Add( aNewEdge )) continue; // faces interfering by aNewEdge itF.Initialize (myAsDes->Ascendant( aNewEdge )); for (; itF.More(); itF.Next()) if (aCheckFace != itF.Value()) anIntFaces.Append( itF.Value() ); // ** 2. faces having section edge aNewEdge on aFacesToCheck if (EFM.Contains( aNewEdge)) { itF.Initialize ( EFM.FindFromKey (itE.Value())); for (; itF.More(); itF.Next()) if (aCheckFace != itF.Value()) anIntFaces.Append( itF.Value() ); } } } // ** 3. faces cut by edges of aCheckFace TopExp_Explorer expE (aCheckFace, TopAbs_EDGE); for ( ; expE.More(); expE.Next()) { const TopoDS_Shape & aCheckEdge = expE.Current(); if (aCheckedShapes.Add( aCheckEdge ) && myInter3d.IsSectionEdge( TopoDS::Edge( aCheckEdge ))) { itF.Initialize( myInter3d.SectionEdgeFaces( TopoDS::Edge( aCheckEdge ))); for (; itF.More(); itF.Next()) if (aCheckFace != itF.Value()) anIntFaces.Append( itF.Value() ); } } // process faces interfering with aCheckFace and shapes they // belong to for (itF.Initialize (anIntFaces); itF.More(); itF.Next()) { const TopoDS_Shape & F = itF.Value(); if (! aCheckedShapes.Add( F )) continue; Standard_Boolean isTool = myMapTools.Contains( F ); if (isTool && myFaceShapeMap( aCheckFace ).ShapeType() == TopAbs_SOLID ) { // a tool interfering with a solid if (aSectionFaces.Contains( F )) AddShape( F ); ++ nbFoundTools; if (nbFoundTools == myMapTools.Extent()) return; } const TopoDS_Shape & S = myFaceShapeMap( F ); if (aCheckedShapes.Add( S )) { // a new shape interefering with aCurrentSolids is found if (!isTool && S.ShapeType() == TopAbs_SOLID) aCurrentSolids.Add ( S ); // add faces to aFacesToCheck list for ( exp.Init( S, TopAbs_FACE ); exp.More(); exp.Next()) aFacesToCheck.Append ( exp.Current() ); } } } // loop on aFacesToCheck // Here aCurrentSolids contains all solids interfering with each other. // aCheckedShapes contains all faces belonging to shapes included // in or interfering with aCurrentSolids or previously checked solids. // Test if tool faces that do not interefere with other shapes are // wrapped by any of aCurrentSolids TopTools_MapIteratorOfMapOfShape aSolidIt (aCurrentSolids); for ( ; aSolidIt.More(); aSolidIt.Next()) { const TopoDS_Shape & aSolid = aSolidIt.Key(); TopTools_MapOfShape aCheckedTools( myMapTools.Extent() ); TopTools_MapIteratorOfMapOfShape aToolIt (myMapTools); for ( ; aToolIt.More(); aToolIt.Next()) { const TopoDS_Shape & aToolFace = aToolIt.Key(); if (aCheckedShapes.Contains( aToolFace ) || // already found aCheckedTools.Contains( aToolFace )) // checked against aSolid continue; const TopoDS_Shape & aToolShape = myFaceShapeMap( aToolFace ); TopExp_Explorer aToolFaceIt( aToolShape, TopAbs_FACE ); Standard_Boolean isInside = IsInside( aToolShape, aSolid ); for ( ; aToolFaceIt.More(); aToolFaceIt.Next() ) { const TopoDS_Shape & aTool = aToolFaceIt.Current(); aCheckedTools.Add( aTool ); if (isInside) { if (aSectionFaces.Contains( aTool )) AddShape( aTool ); ++ nbFoundTools; if (nbFoundTools == myMapTools.Extent()) return; aCheckedShapes.Add( aTool ); } } } } } // loop on solid shapes } } #endif netgen-4.9.13/libsrc/occ/Partition_Loop2d.jxx0000644000175000001440000000077711244373410015764 00000000000000// GEOM PARTITION : partition algorithm // // Copyright (C) 2003 CEA/DEN, EDF R&D // // // // File : Partition_Loop2d.jxx // Module : GEOM #ifndef _TopoDS_Face_HeaderFile #include #endif #ifndef _TopoDS_Edge_HeaderFile #include #endif #ifndef _TopTools_ListOfShape_HeaderFile #include #endif #ifndef _BRepAlgo_Image_HeaderFile #include #endif #ifndef _Partition_Loop2d_HeaderFile #include "Partition_Loop2d.hxx" #endif netgen-4.9.13/libsrc/occ/occconstruction.cpp0000644000175000001440000000760711244375717015777 00000000000000 #ifdef OCCGEOMETRY #include #include #include "ShapeAnalysis_ShapeTolerance.hxx" #include "ShapeAnalysis_ShapeContents.hxx" #include "ShapeAnalysis_CheckSmallFace.hxx" #include "ShapeAnalysis_DataMapOfShapeListOfReal.hxx" #include "BRepAlgoAPI_Fuse.hxx" #include "BRepCheck_Analyzer.hxx" #include "BRepLib.hxx" #include "ShapeBuild_ReShape.hxx" #include "ShapeFix.hxx" #include "ShapeFix_FixSmallFace.hxx" #include "Partition_Spliter.hxx" //#include "VrmlAPI.hxx" //#include "StlAPI.hxx" #include #include #include #include // #include #include #include #include #include #include #include //#include #include #include namespace netgen { void OCCConstructGeometry (OCCGeometry & geom) { #ifdef NOTHING cout << "OCC construction" << endl; BRep_Builder builder; BRepPrimAPI_MakeBox mbox(gp_Pnt(-10e5, -15e5, 0), gp_Pnt(20e5, 15e5, 10e5)); /* TopoDS_Shape air = TopoDS_Solid (mbox); air = BRepAlgoAPI_Cut (air, geom.somap(1)); air = BRepAlgoAPI_Cut (air, geom.somap(2)); air = BRepAlgoAPI_Cut (air, geom.somap(3)); air = BRepAlgoAPI_Cut (air, geom.somap(4)); air = BRepAlgoAPI_Cut (air, geom.somap(5)); air = BRepAlgoAPI_Cut (air, geom.somap(6)); air = BRepAlgoAPI_Cut (air, geom.somap(7)); // air = BRepAlgoAPI_Cut (air, geom.somap(8)); air = BRepAlgoAPI_Cut (air, geom.somap(9)); // air = BRepAlgoAPI_Cut (air, geom.somap(10)); */ /* BRepOffsetAPI_MakeOffsetShape dom8plus (geom.somap(8), 1e4, 1e-6); BRepOffsetAPI_MakeOffsetShape dom6plus (geom.somap(6), 1e4, 1e-6); dom8plus.Build(); ShapeFix_Shape fixshape(dom8plus.Shape()); fixshape.Perform(); ShapeFix_Shape fix_dom2(geom.somap(2)); fix_dom2.Perform(); BRepAlgoAPI_Cut dom2m8(fix_dom2.Shape(), fixshape.Shape()); ShapeFix_Shape fix_dom2m8 (dom2m8); fix_dom2m8.Perform(); builder.Add (geom.shape, BRepAlgoAPI_Cut (BRepAlgoAPI_Cut (geom.somap(2), dom6plus), dom8plus)); // builder.Add (geom.shape, fix_dom2m8.Shape()); // builder.Add (geom.shape, fixshape.Shape()); */ TopoDS_Shape my_fuse; int cnt = 0; for (TopExp_Explorer exp_solid(geom.shape, TopAbs_SOLID); exp_solid.More(); exp_solid.Next()) { if (cnt == 0) my_fuse = exp_solid.Current(); else { cout << "fuse, cnt = " << cnt << endl; if (cnt != 7 && cnt != 9) my_fuse = BRepAlgoAPI_Fuse (my_fuse, exp_solid.Current()); } cnt++; } builder.Add (geom.shape, my_fuse); /* ShapeUpgrade_ShellSewing ss; ss.ApplySewing(geom.shape,1e5); */ /* BRepAlgo_Sewing sewing(1.e5); int cnt = 0; for (TopExp_Explorer exp_solid(geom.shape, TopAbs_SOLID); exp_solid.More(); exp_solid.Next()) { cout << "swe, cnt = " << cnt << endl; if (cnt != 7 && cnt != 9) sewing.Add (exp_solid.Current()); cnt++; } sewing.Perform(); builder.Add (geom.shape, sewing.SewedShape()); */ /* cout << "build air domain" << endl; TopoDS_Shape air = BRepAlgoAPI_Cut (TopoDS_Solid (mbox), my_fuse); cnt = 0; for (TopExp_Explorer exp_solid(geom.shape, TopAbs_SOLID); exp_solid.More(); exp_solid.Next()) { cout << "section, cnt = " << cnt << endl; if (cnt == 7) { builder.Add (geom.shape, BRepAlgoAPI_Section (air, exp_solid.Current())); } cnt++; } */ // builder.Add (geom.shape, air); for (int i = 1; i <= 10; i++) builder.Remove (geom.shape, geom.somap(i)); geom.BuildFMap(); geom.BuildVisualizationMesh(); geom.changed = 1; #endif } } #endif netgen-4.9.13/libsrc/occ/Partition_Spliter.ixx0000644000175000001440000000207111244373410016233 00000000000000// GEOM PARTITION : partition algorithm // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // // File : Partition_Spliter.ixx // Module : GEOM #include "Partition_Spliter.jxx" netgen-4.9.13/libsrc/occ/utilities.h0000644000175000001440000000671111244373410014217 00000000000000// SALOME Utils : general SALOME's definitions and tools // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // // File : utilities.h // Author : Antoine YESSAYAN, Paul RASCLE, EDF // Module : SALOME // $Header: /cvs/netgen/netgen/libsrc/occ/utilities.h,v 1.3 2008/03/31 14:20:28 wabro Exp $ /* --- Definition macros file to print informations if _DEBUG_ is defined --- */ #ifndef UTILITIES_H #define UTILITIES_H #include #include #include // #include "SALOME_Log.hxx" /* --- INFOS is always defined (without _DEBUG_): to be used for warnings, with release version --- */ #define INFOS(msg) {SLog->putMessage(*SLog<<__FILE__<<" ["<<__LINE__<<"] : "<putMessage(*SLog<<"---PYSCRIPT--- "<putMessage(\ *SLog<<__FILE__<<" ["<< __LINE__<<"] : "\ << "COMPILED with " << COMPILER \ << ", " << __DATE__ \ << " at " << __TIME__ <putMessage( MYTRACE <putMessage( MYTRACE << #var << "=" << var < lami; Point<3> p; }; int surfellist; int linelist; int clipplanelist; int isolinelist; int clipplane_isolinelist; int surface_vector_list; // int cone_list; int isosurface_list; int pointcurvelist; bool draw_fieldlines; bool drawpointcurves; bool draw_isosurface; int num_fieldlines; bool fieldlines_randomstart; int fieldlineslist; int num_fieldlineslists; int fieldlines_startarea; Array fieldlines_startarea_parameter; int fieldlines_startface; string fieldlines_filename; double fieldlines_reltolerance; int fieldlines_rktype; double fieldlines_rellength; double fieldlines_relthickness; int fieldlines_vecfunction; bool fieldlines_fixedphase; float fieldlines_phase; int fieldlines_maxpoints; int surfeltimestamp, clipplanetimestamp, solutiontimestamp; int surfellinetimestamp; int fieldlinestimestamp, surface_vector_timestamp; int pointcurve_timestamp; int isosurface_timestamp; int subdivision_timestamp; int timetimestamp; double minval, maxval; NgLock *lock; #ifdef PARALLELGL Array par_linelists; Array par_surfellists; #endif public: enum EvalFunc { FUNC_ABS = 1, FUNC_ABS_TENSOR = 2, FUNC_MISES = 3, FUNC_MAIN = 4 }; EvalFunc evalfunc; enum SolType { SOL_NODAL = 1, SOL_ELEMENT = 2, SOL_SURFACE_ELEMENT = 3, SOL_NONCONTINUOUS = 4, SOL_SURFACE_NONCONTINUOUS = 5, SOL_VIRTUALFUNCTION = 6, SOL_MARKED_ELEMENTS = 10, SOL_ELEMENT_ORDER = 11, }; class SolData { public: SolData (); ~SolData (); char * name; double * data; int components; int dist; int order; bool iscomplex; bool draw_volume; bool draw_surface; SolType soltype; SolutionData * solclass; // internal variables: int size; }; Array soldata; int usetexture; // 0..no, 1..1D texture (standard), 2..2D-texture (complex) int clipsolution; // 0..no, 1..scal, 2..vec int scalfunction, scalcomp, vecfunction; int gridsize; double xoffset, yoffset; int autoscale, logscale; double mminval, mmaxval; int numisolines; int subdivisions; bool showclipsolution; bool showsurfacesolution; bool lineartexture; int numtexturecols; int multidimcomponent; // bool fieldlineplot; double time; int deform; double scaledeform; bool imag_part; private: void BuildFieldLinesFromFile(Array & startpoints); void BuildFieldLinesFromFace(Array & startpoints); void BuildFieldLinesFromBox(Array & startpoints); void BuildFieldLinesFromLine(Array & startpoints); public: VisualSceneSolution (); virtual ~VisualSceneSolution (); virtual void BuildScene (int zoomall = 0); virtual void DrawScene (); virtual void MouseDblClick (int px, int py); void BuildFieldLinesPlot (); void AddSolutionData (SolData * soldata); void ClearSolutionData (); void UpdateSolutionTimeStamp (); SolData * GetSolData (int i); int GetNSolData () { return soldata.Size(); } void SaveSolutionData (const char * filename); static void RealVec3d (const double * values, Vec3d & v, bool iscomplex, bool imag); static void RealVec3d (const double * values, Vec3d & v, bool iscomplex, double phaser, double phasei); void SetSubdivision (int sd) { subdivisions = sd; subdivision_timestamp = solutiontimestamp = NextTimeStamp(); } private: void GetMinMax (int funcnr, int comp, double & minv, double & maxv) const; void GetClippingPlaneTrigs (Array & trigs, Array & pts); void GetClippingPlaneGrid (Array & pts); void DrawCone (const Point<3> & p1, const Point<3> & p2, double r); void DrawCylinder (const Point<3> & p1, const Point<3> & p2, double r); // Get Function Value, local coordinates lam1, lam2, lam3, bool GetValue (const SolData * data, ElementIndex elnr, double lam1, double lam2, double lam3, int comp, double & val) const; bool GetValue (const SolData * data, ElementIndex elnr, const double xref[], const double x[], const double dxdxref[], int comp, double & val) const; bool GetValueComplex (const SolData * data, ElementIndex elnr, double lam1, double lam2, double lam3, int comp, complex & val) const; bool GetValues (const SolData * data, ElementIndex elnr, double lam1, double lam2, double lam3, double * values) const; bool GetValues (const SolData * data, ElementIndex elnr, const double xref[], const double x[], const double dxdxref[], double * values) const; bool GetMultiValues (const SolData * data, ElementIndex elnr, int npt, const double * xref, int sxref, const double * x, int sx, const double * dxdxref, int sdxdxref, double * val, int sval) const; bool GetSurfValue (const SolData * data, SurfaceElementIndex elnr, double lam1, double lam2, int comp, double & val) const; bool GetSurfValue (const SolData * data, SurfaceElementIndex elnr, const double xref[], const double x[], const double dxdxref[], int comp, double & val) const; bool GetSurfValueComplex (const SolData * data, SurfaceElementIndex elnr, double lam1, double lam2, int comp, complex & val) const; bool GetSurfValues (const SolData * data, SurfaceElementIndex elnr, double lam1, double lam2, double * values) const; bool GetSurfValues (const SolData * data, SurfaceElementIndex elnr, const double xref[], const double x[], const double dxdxref[], double * values) const; bool GetMultiSurfValues (const SolData * data, SurfaceElementIndex elnr, int npt, const double * xref, int sxref, const double * x, int sx, const double * dxdxref, int sdxdxref, double * val, int sval) const; double ExtractValue (const SolData * data, int comp, double * values) const; complex ExtractValueComplex (const SolData * data, int comp, double * values) const; Vec<3> GetDeformation (ElementIndex elnr, const Point<3> & p) const; Vec<3> GetSurfDeformation (SurfaceElementIndex selnr, double lam1, double lam2) const; void GetPointDeformation (int pnum, Point<3> & p, SurfaceElementIndex elnr = -1) const; public: /// draw elements (build lists) void DrawSurfaceElements (); void DrawSurfaceElementLines (); void DrawSurfaceVectors (); void DrawTrigSurfaceVectors(const Array< Point<3> > & lp, const Point<3> & pmin, const Point<3> & pmax, const int sei, const SolData * vsol); void DrawIsoSurface(const SolData * sol, const SolData * grad, int comp); void DrawIsoLines (const Point<3> & p1, const Point<3> & p2, const Point<3> & p3, double val1, double val2, double val3); // double minval, double maxval, int n); // draw isolines between lines (p1,p2) and (p3,p4) void DrawIsoLines2 (const Point<3> & p1, const Point<3> & p2, const Point<3> & p3, const Point<3> & p4, double val1, double val2, double val3, double val4); // double minval, double maxval, int n); void DrawClipPlaneTrigs (const SolData * sol, int comp, const Array & trigs, const Array & points); // void SetOpenGlColor(double val, double valmin, double valmax, int logscale = 0); void SetOpenGlColor(double val); // 0 .. non, 1 .. scalar, 2 .. complex void SetTextureMode (int texturemode) const; #ifndef SMALLLIB #ifndef NOTCL friend int Ng_Vis_Set (ClientData clientData, Tcl_Interp * interp, int argc, tcl_const char *argv[]); #endif #endif #ifdef PARALLELGL void Broadcast (); #endif }; class RKStepper { private: Array c,b; TABLE *a; int steps; int order; double tolerance; Array K; int stepcount; double h; double startt; double startt_bak; Point3d startval; Point3d startval_bak; bool adaptive; int adrun; Point3d valh; int notrestarted; public: ~RKStepper(); RKStepper(int type = 0); void SetTolerance(const double tol){tolerance = tol;} void StartNextValCalc(const Point3d & astartval, const double astartt, const double ah, const bool aadaptive = false); bool GetNextData(Point3d & val, double & t, double & ah); bool FeedNextF(const Vec3d & f); }; class FieldLineCalc { private: const Mesh & mesh; VisualSceneSolution & vss; const VisualSceneSolution::SolData * vsol; RKStepper stepper; double maxlength; int maxpoints; int direction; Point3d pmin, pmax; double rad; double phaser, phasei; double critical_value; bool randomized; double thickness; public: FieldLineCalc(const Mesh & amesh, VisualSceneSolution & avss, const VisualSceneSolution::SolData * solution, const double rel_length, const int amaxpoints = -1, const double rel_thickness = -1, const double rel_tolerance = -1, const int rk_type = 0, const int adirection = 0); void SetPhase(const double real, const double imag) { phaser = real; phasei = imag; } void SetCriticalValue(const double val) { critical_value = val; } void Randomized(void) { randomized = true; } void NotRandomized(void) { randomized = false; } void Calc(const Point3d & startpoint, Array & points, Array & vals, Array & drawelems, Array & dirstart); void GenerateFieldLines(Array & potential_startpoints, const int numlines, const int gllist, const double minval, const double maxval, const int logscale, double phaser, double phasei); }; extern VisualSceneSolution vssolution; #endif netgen-4.9.13/libsrc/visualization/Makefile.am0000644000175000001440000000071211240003502016203 00000000000000noinst_HEADERS = meshdoc.hpp mvdraw.hpp vispar.hpp \ visual.hpp vssolution.hpp include_HEADERS = soldata.hpp AM_CPPFLAGS = $(MPI_INCLUDES) -I$(top_srcdir)/libsrc/include -DOPENGL -D$(TOGL_WINDOWINGSYSTEM) $(OCCFLAGS) $(TCL_INCLUDES) METASOURCES = AUTO noinst_LIBRARIES = libvisual.a libvisual_a_SOURCES = meshdoc.cpp mvdraw.cpp stlmeshing.cpp vscsg.cpp \ vsfieldlines.cpp vsmesh.cpp vsocc.cpp vssolution.cpp importsolution.cpp AM_CXXFLAGS = -DOPENGL netgen-4.9.13/libsrc/visualization/meshdoc.hpp0000644000175000001440000000122111240003502016276 00000000000000 class VisualSceneMeshDoctor : public VisualScene { int filledlist; int outlinelist; int edgelist; int selelement, locpi; int selpoint, selpoint2; // for edgemarking: Array edgedist; int markedgedist; public: VisualSceneMeshDoctor (); virtual ~VisualSceneMeshDoctor (); virtual void BuildScene (int zoomall = 0); virtual void DrawScene (); virtual void MouseDblClick (int px, int py); void SetMarkEdgeDist (int dist); void ClickElement (int elnr); void UpdateTables (); int IsSegmentMarked (int segnr) const; }; class MeshDoctorParameters { public: int active; }; extern MeshDoctorParameters meshdoctor; netgen-4.9.13/libsrc/visualization/Makefile.in0000644000175000001440000004150011375342730016236 00000000000000# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = libsrc/visualization DIST_COMMON = $(include_HEADERS) $(noinst_HEADERS) \ $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/tcl.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = LIBRARIES = $(noinst_LIBRARIES) ARFLAGS = cru libvisual_a_AR = $(AR) $(ARFLAGS) libvisual_a_LIBADD = am_libvisual_a_OBJECTS = meshdoc.$(OBJEXT) mvdraw.$(OBJEXT) \ stlmeshing.$(OBJEXT) vscsg.$(OBJEXT) vsfieldlines.$(OBJEXT) \ vsmesh.$(OBJEXT) vsocc.$(OBJEXT) vssolution.$(OBJEXT) \ importsolution.$(OBJEXT) libvisual_a_OBJECTS = $(am_libvisual_a_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libvisual_a_SOURCES) DIST_SOURCES = $(libvisual_a_SOURCES) am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; am__installdirs = "$(DESTDIR)$(includedir)" includeHEADERS_INSTALL = $(INSTALL_HEADER) HEADERS = $(include_HEADERS) $(noinst_HEADERS) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH = @CYGPATH@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FFMPEG_INCLUDES = @FFMPEG_INCLUDES@ FFMPEG_LIBS = @FFMPEG_LIBS@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ JPEGLIB_INCLUDES = @JPEGLIB_INCLUDES@ JPEGLIB_LIBS = @JPEGLIB_LIBS@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBGLU = @LIBGLU@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MPI_INCLUDES = @MPI_INCLUDES@ MPI_LIBS = @MPI_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OCCFLAGS = @OCCFLAGS@ OCCLIBS = @OCCLIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CFLAGS = @PKG_CFLAGS@ PKG_HEADERS = @PKG_HEADERS@ PKG_INCLUDES = @PKG_INCLUDES@ PKG_LIBS = @PKG_LIBS@ PKG_LIB_FILE = @PKG_LIB_FILE@ PKG_STUB_LIB_FILE = @PKG_STUB_LIB_FILE@ PKG_STUB_OBJECTS = @PKG_STUB_OBJECTS@ PKG_STUB_SOURCES = @PKG_STUB_SOURCES@ PKG_TCL_SOURCES = @PKG_TCL_SOURCES@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ TCL_BIN_DIR = @TCL_BIN_DIR@ TCL_DEFS = @TCL_DEFS@ TCL_EXTRA_CFLAGS = @TCL_EXTRA_CFLAGS@ TCL_INCLUDES = @TCL_INCLUDES@ TCL_LD_FLAGS = @TCL_LD_FLAGS@ TCL_LIBS = @TCL_LIBS@ TCL_LIB_FILE = @TCL_LIB_FILE@ TCL_LIB_FLAG = @TCL_LIB_FLAG@ TCL_LIB_SPEC = @TCL_LIB_SPEC@ TCL_SHLIB_LD_LIBS = @TCL_SHLIB_LD_LIBS@ TCL_SRC_DIR = @TCL_SRC_DIR@ TCL_STUB_LIB_FILE = @TCL_STUB_LIB_FILE@ TCL_STUB_LIB_FLAG = @TCL_STUB_LIB_FLAG@ TCL_STUB_LIB_SPEC = @TCL_STUB_LIB_SPEC@ TCL_VERSION = @TCL_VERSION@ TK_BIN_DIR = @TK_BIN_DIR@ TK_LIBS = @TK_LIBS@ TK_LIB_FILE = @TK_LIB_FILE@ TK_LIB_FLAG = @TK_LIB_FLAG@ TK_LIB_SPEC = @TK_LIB_SPEC@ TK_SRC_DIR = @TK_SRC_DIR@ TK_STUB_LIB_FILE = @TK_STUB_LIB_FILE@ TK_STUB_LIB_FLAG = @TK_STUB_LIB_FLAG@ TK_STUB_LIB_SPEC = @TK_STUB_LIB_SPEC@ TK_VERSION = @TK_VERSION@ TK_XINCLUDES = @TK_XINCLUDES@ TOGLLIBDIR = @TOGLLIBDIR@ TOGL_WINDOWINGSYSTEM = @TOGL_WINDOWINGSYSTEM@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_HEADERS = meshdoc.hpp mvdraw.hpp vispar.hpp \ visual.hpp vssolution.hpp include_HEADERS = soldata.hpp AM_CPPFLAGS = $(MPI_INCLUDES) -I$(top_srcdir)/libsrc/include -DOPENGL -D$(TOGL_WINDOWINGSYSTEM) $(OCCFLAGS) $(TCL_INCLUDES) METASOURCES = AUTO noinst_LIBRARIES = libvisual.a libvisual_a_SOURCES = meshdoc.cpp mvdraw.cpp stlmeshing.cpp vscsg.cpp \ vsfieldlines.cpp vsmesh.cpp vsocc.cpp vssolution.cpp importsolution.cpp AM_CXXFLAGS = -DOPENGL all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libsrc/visualization/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --foreign libsrc/visualization/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) libvisual.a: $(libvisual_a_OBJECTS) $(libvisual_a_DEPENDENCIES) -rm -f libvisual.a $(libvisual_a_AR) libvisual.a $(libvisual_a_OBJECTS) $(libvisual_a_LIBADD) $(RANLIB) libvisual.a mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/importsolution.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/meshdoc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mvdraw.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stlmeshing.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vscsg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vsfieldlines.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vsmesh.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vsocc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vssolution.Po@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs install-includeHEADERS: $(include_HEADERS) @$(NORMAL_INSTALL) test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)" @list='$(include_HEADERS)'; for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ f=$(am__strip_dir) \ echo " $(includeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(includedir)/$$f'"; \ $(includeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(includedir)/$$f"; \ done uninstall-includeHEADERS: @$(NORMAL_UNINSTALL) @list='$(include_HEADERS)'; for p in $$list; do \ f=$(am__strip_dir) \ echo " rm -f '$(DESTDIR)$(includedir)/$$f'"; \ rm -f "$(DESTDIR)$(includedir)/$$f"; \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LIBRARIES) $(HEADERS) installdirs: for dir in "$(DESTDIR)$(includedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am info: info-am info-am: install-data-am: install-includeHEADERS install-dvi: install-dvi-am install-exec-am: install-html: install-html-am install-info: install-info-am install-man: install-pdf: install-pdf-am install-ps: install-ps-am installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-includeHEADERS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool clean-noinstLIBRARIES ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-includeHEADERS install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-includeHEADERS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: netgen-4.9.13/libsrc/visualization/vsocc.cpp0000644000175000001440000004753211252505157016023 00000000000000#ifndef NOTCL #ifdef OCCGEOMETRY #include #include #include #include #include "TopoDS_Shape.hxx" #include "TopoDS_Vertex.hxx" #include "TopExp_Explorer.hxx" #include "BRep_Tool.hxx" #include "TopoDS.hxx" #include "gp_Pnt.hxx" #include "Geom_Curve.hxx" #include "Poly_Triangulation.hxx" #include "Poly_Array1OfTriangle.hxx" #include "TColgp_Array1OfPnt2d.hxx" #include "Poly_Triangle.hxx" #include "Poly_Polygon3D.hxx" #include "Poly_PolygonOnTriangulation.hxx" #include namespace netgen { extern OCCGeometry * occgeometry; /* *********************** Draw OCC Geometry **************** */ VisualSceneOCCGeometry :: VisualSceneOCCGeometry () : VisualScene() { trilists.SetSize(0); linelists.SetSize(1); } VisualSceneOCCGeometry :: ~VisualSceneOCCGeometry () { ; } void VisualSceneOCCGeometry :: DrawScene () { if ( occgeometry->changed ) { BuildScene(); occgeometry -> changed = 0; } glClearColor(backcolor, backcolor, backcolor, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); SetLight(); glPushMatrix(); glMultMatrixf (transformationmat); glShadeModel (GL_SMOOTH); glDisable (GL_COLOR_MATERIAL); glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // glEnable (GL_LIGHTING); double shine = vispar.shininess; // double transp = vispar.transp; glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, shine); glLogicOp (GL_COPY); glEnable (GL_NORMALIZE); float mat_col[] = { 0.2f, 0.2f, 0.8f, 1.0f}; glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col); glPolygonOffset (1, 1); glEnable (GL_POLYGON_OFFSET_FILL); // Philippose - 30/01/2009 // Added clipping planes to Geometry view SetClippingPlane(); GLfloat matcoledge[] = { 0, 0, 1, 1}; GLfloat matcolhiedge[] = { 1, 0, 0, 1}; glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, matcoledge); glLineWidth (1.0f); if (vispar.occshowedges) glCallList (linelists.Get(1)); if (vispar.occshowsurfaces) glCallList (trilists.Get(1)); glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, matcolhiedge); glLineWidth (5.0f); if (vispar.occshowedges) glCallList (linelists.Get(2)); for (int i = 1; i <= occgeometry->vmap.Extent(); i++) if (occgeometry->vvispar[i-1].IsHighlighted()) { glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, matcolhiedge); glLineWidth (5.0f); glBegin (GL_LINES); gp_Pnt p = BRep_Tool::Pnt(TopoDS::Vertex(occgeometry->vmap(i))); double d = rad/100; glVertex3f (p.X()-d, p.Y(), p.Z()); glVertex3f (p.X()+d, p.Y(), p.Z()); glVertex3f (p.X(), p.Y()-d, p.Z()); glVertex3f (p.X(), p.Y()+d, p.Z()); glVertex3f (p.X(), p.Y(), p.Z()-d); glVertex3f (p.X(), p.Y(), p.Z()+d); glEnd(); } glDisable (GL_POLYGON_OFFSET_FILL); glPopMatrix(); // DrawCoordinateCross (); // DrawNetgenLogo (); glFinish(); glDisable (GL_POLYGON_OFFSET_FILL); } /* void VisualSceneOCCGeometry :: BuildScene (int zoomall) { int i = 0, j, k; TopExp_Explorer ex, ex_edge; if (vispar.occvisproblemfaces || (occgeometry -> changed != 2)) { Box<3> bb = occgeometry -> GetBoundingBox(); center = bb.Center(); rad = bb.Diam() / 2; if (vispar.occvisproblemfaces) { for (i = 1; i <= occgeometry->fmap.Extent(); i++) if (occgeometry->facemeshstatus[i-1] == -1) { GProp_GProps system; BRepGProp::LinearProperties(occgeometry->fmap(i), system); gp_Pnt pnt = system.CentreOfMass(); center = Point<3> (pnt.X(), pnt.Y(), pnt.Z()); cout << "Setting center to mid of face " << i << " = " << center << endl; } } CalcTransformationMatrices(); } for (i = 1; i <= linelists.Size(); i++) glDeleteLists (linelists.Elem(i), 1); linelists.SetSize(0); linelists.Append (glGenLists (1)); glNewList (linelists.Last(), GL_COMPILE); i = 0; for (ex_edge.Init(occgeometry -> shape, TopAbs_EDGE); ex_edge.More(); ex_edge.Next()) { if (BRep_Tool::Degenerated(TopoDS::Edge(ex_edge.Current()))) continue; i++; TopoDS_Edge edge = TopoDS::Edge(ex_edge.Current()); Handle(Poly_PolygonOnTriangulation) aEdgePoly; Handle(Poly_Triangulation) T; TopLoc_Location aEdgeLoc; BRep_Tool::PolygonOnTriangulation(edge, aEdgePoly, T, aEdgeLoc); if(aEdgePoly.IsNull()) { cout << "cannot visualize edge " << i << endl; continue; } glBegin (GL_LINE_STRIP); int nbnodes = aEdgePoly -> NbNodes(); for (j = 1; j <= nbnodes; j++) { gp_Pnt p = (T -> Nodes())(aEdgePoly->Nodes()(j)).Transformed(aEdgeLoc); glVertex3f (p.X(), p.Y(), p.Z()); } glEnd (); } glEndList (); for (i = 1; i <= trilists.Size(); i++) glDeleteLists (trilists.Elem(i), 1); trilists.SetSize(0); trilists.Append (glGenLists (1)); glNewList (trilists.Last(), GL_COMPILE); i = 0; TopExp_Explorer exp0, exp1, exp2, exp3; int shapenr = 0; for (exp0.Init(occgeometry -> shape, TopAbs_SOLID); exp0.More(); exp0.Next()) { shapenr++; if (vispar.occshowvolumenr != 0 && vispar.occshowvolumenr != shapenr) continue; float mat_col[4]; mat_col[3] = 1; switch (shapenr) { case 1: mat_col[0] = 0.2; mat_col[1] = 0.2; mat_col[2] = 0.8; break; case 2: mat_col[0] = 0.8; mat_col[1] = 0.2; mat_col[2] = 0.8; break; case 3: mat_col[0] = 0.2; mat_col[1] = 0.8; mat_col[2] = 0.8; break; case 4: mat_col[0] = 0.8; mat_col[1] = 0.2; mat_col[2] = 0.2; break; case 5: mat_col[0] = 0.8; mat_col[1] = 0.8; mat_col[2] = 0.8; break; case 6: mat_col[0] = 0.6; mat_col[1] = 0.6; mat_col[2] = 0.6; break; case 7: mat_col[0] = 0.2; mat_col[1] = 0.8; mat_col[2] = 0.2; break; case 8: mat_col[0] = 0.8; mat_col[1] = 0.8; mat_col[2] = 0.2; break; default: // mat_col[0] = 1-(1.0/double(shapenr)); // mat_col[1] = 0.5; mat_col[0] = 0.5+double((shapenr*shapenr*shapenr*shapenr) % 10)/20.0; mat_col[1] = 0.5+double(int(shapenr*shapenr*shapenr*shapenr*sin(double(shapenr))) % 10)/20.0; mat_col[2] = 0.5+double((shapenr*shapenr*shapenr) % 10)/20.0; } glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col); for (exp1.Init(exp0.Current(), TopAbs_SHELL); exp1.More(); exp1.Next()) for (exp2.Init(exp1.Current().Composed(exp0.Current().Orientation()), TopAbs_FACE); exp2.More(); exp2.Next()) { TopoDS_Face face = TopoDS::Face (exp2.Current().Composed(exp1.Current().Orientation())); i = occgeometry->fmap.FindIndex(face); TopLoc_Location loc; Handle(Geom_Surface) surf = BRep_Tool::Surface (face); BRepAdaptor_Surface sf(face, Standard_False); BRepLProp_SLProps prop(sf, 1, 1e-5); Handle(Poly_Triangulation) triangulation = BRep_Tool::Triangulation (face, loc); if (triangulation.IsNull()) { cout << "cannot visualize face " << i << endl; continue; } if (vispar.occvisproblemfaces) { switch (occgeometry->facemeshstatus[i-1]) { case 0: mat_col[0] = 0.2; mat_col[1] = 0.2; mat_col[2] = 0.8; break; case 1: mat_col[0] = 0.2; mat_col[1] = 0.8; mat_col[2] = 0.2; break; case -1: mat_col[0] = 0.8; mat_col[1] = 0.2; mat_col[2] = 0.2; break; } glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col); } glBegin (GL_TRIANGLES); int ntriangles = triangulation -> NbTriangles(); for (j = 1; j <= ntriangles; j++) { Poly_Triangle triangle = (triangulation -> Triangles())(j); for (k = 1; k <= 3; k++) { gp_Pnt2d uv = (triangulation -> UVNodes())(triangle(k)); gp_Pnt pnt; gp_Vec du, dv; prop.SetParameters (uv.X(), uv.Y()); surf->D0 (uv.X(), uv.Y(), pnt); gp_Vec n; if (prop.IsNormalDefined()) n = prop.Normal(); else n = gp_Vec (0,0,0); if (face.Orientation() == TopAbs_REVERSED) n *= -1; glNormal3f (n.X(), n.Y(), n.Z()); glVertex3f (pnt.X(), pnt.Y(), pnt.Z()); } } glEnd (); } } glEndList (); } */ void VisualSceneOCCGeometry :: BuildScene (int zoomall) { if (occgeometry -> changed == OCCGEOMETRYVISUALIZATIONFULLCHANGE) { occgeometry -> BuildVisualizationMesh (vispar.occdeflection); center = occgeometry -> Center(); rad = occgeometry -> GetBoundingBox().Diam() / 2; if (vispar.occzoomtohighlightedentity) { bool hilite = false; bool hiliteonepoint = false; Bnd_Box bb; for (int i = 1; i <= occgeometry->fmap.Extent(); i++) if (occgeometry->fvispar[i-1].IsHighlighted()) { hilite = true; BRepBndLib::Add (occgeometry->fmap(i), bb); } for (int i = 1; i <= occgeometry->emap.Extent(); i++) if (occgeometry->evispar[i-1].IsHighlighted()) { hilite = true; BRepBndLib::Add (occgeometry->emap(i), bb); } for (int i = 1; i <= occgeometry->vmap.Extent(); i++) if (occgeometry->vvispar[i-1].IsHighlighted()) { hiliteonepoint = true; BRepBndLib::Add (occgeometry->vmap(i), bb); } if (hilite || hiliteonepoint) { double x1,y1,z1,x2,y2,z2; bb.Get (x1,y1,z1,x2,y2,z2); Point<3> p1 = Point<3> (x1,y1,z1); Point<3> p2 = Point<3> (x2,y2,z2); Box<3> boundingbox(p1,p2); center = boundingbox.Center(); if (hiliteonepoint) rad = occgeometry -> GetBoundingBox().Diam() / 100; else rad = boundingbox.Diam() / 2; } } CalcTransformationMatrices(); } // Clear lists for (int i = 1; i <= linelists.Size(); i++) glDeleteLists (linelists.Elem(i), 1); linelists.SetSize(0); for (int i = 1; i <= trilists.Size(); i++) glDeleteLists (trilists.Elem(i), 1); trilists.SetSize(0); // Total wireframe linelists.Append (glGenLists (1)); glNewList (linelists.Last(), GL_COMPILE); for (int i = 1; i <= occgeometry->emap.Extent(); i++) { TopoDS_Edge edge = TopoDS::Edge(occgeometry->emap(i)); if (BRep_Tool::Degenerated(edge)) continue; if (occgeometry->evispar[i-1].IsHighlighted()) continue; Handle(Poly_PolygonOnTriangulation) aEdgePoly; Handle(Poly_Triangulation) T; TopLoc_Location aEdgeLoc; BRep_Tool::PolygonOnTriangulation(edge, aEdgePoly, T, aEdgeLoc); if(aEdgePoly.IsNull()) { (*testout) << "visualizing edge " << occgeometry->emap.FindIndex (edge) << " without using the occ visualization triangulation" << endl; double s0, s1; Handle(Geom_Curve) c = BRep_Tool::Curve(edge, s0, s1); glBegin (GL_LINE_STRIP); for (int i = 0; i<=50; i++) { gp_Pnt p = c->Value (s0 + i*(s1-s0)/50.0); glVertex3f (p.X(),p.Y(),p.Z()); } glEnd (); continue; } int nbnodes = aEdgePoly -> NbNodes(); glBegin (GL_LINE_STRIP); for (int j = 1; j <= nbnodes; j++) { gp_Pnt p = (T -> Nodes())(aEdgePoly->Nodes()(j)).Transformed(aEdgeLoc); glVertex3f (p.X(), p.Y(), p.Z()); } glEnd (); } glEndList (); // Highlighted edge list linelists.Append (glGenLists (1)); glNewList (linelists.Last(), GL_COMPILE); for (int i = 1; i <= occgeometry->emap.Extent(); i++) if (occgeometry->evispar[i-1].IsHighlighted()) { TopoDS_Edge edge = TopoDS::Edge(occgeometry->emap(i)); if (BRep_Tool::Degenerated(edge)) continue; Handle(Poly_PolygonOnTriangulation) aEdgePoly; Handle(Poly_Triangulation) T; TopLoc_Location aEdgeLoc; BRep_Tool::PolygonOnTriangulation(edge, aEdgePoly, T, aEdgeLoc); if(aEdgePoly.IsNull()) { (*testout) << "visualizing edge " << occgeometry->emap.FindIndex (edge) << " without using the occ visualization triangulation" << endl; double s0, s1; Handle(Geom_Curve) c = BRep_Tool::Curve(edge, s0, s1); glBegin (GL_LINE_STRIP); for (int i = 0; i<=50; i++) { gp_Pnt p = c->Value (s0 + i*(s1-s0)/50.0); glVertex3f (p.X(),p.Y(),p.Z()); } glEnd (); continue; } int nbnodes = aEdgePoly -> NbNodes(); glBegin (GL_LINE_STRIP); for (int j = 1; j <= nbnodes; j++) { gp_Pnt p = (T -> Nodes())(aEdgePoly->Nodes()(j)).Transformed(aEdgeLoc); glVertex3f (p.X(), p.Y(), p.Z()); } glEnd (); } glEndList (); // display faces trilists.Append (glGenLists (1)); glNewList (trilists.Last(), GL_COMPILE); for (int i = 1; i <= occgeometry->fmap.Extent(); i++) { if (!occgeometry->fvispar[i-1].IsVisible()) continue; glLoadName (i); float mat_col[4]; mat_col[3] = 1; TopoDS_Face face = TopoDS::Face(occgeometry->fmap(i)); if (!occgeometry->fvispar[i-1].IsHighlighted()) { // Philippose - 30/01/2009 // OpenCascade XDE Support Quantity_Color face_colour; // Philippose - 23/02/2009 // Check to see if colours have been extracted first!! // Forum bug-fox (Jean-Yves - 23/02/2009) if(!(occgeometry->face_colours.IsNull()) && (occgeometry->face_colours->GetColor(face,XCAFDoc_ColorSurf,face_colour))) { mat_col[0] = face_colour.Red(); mat_col[1] = face_colour.Green(); mat_col[2] = face_colour.Blue(); } else { mat_col[0] = 0.0; mat_col[1] = 1.0; mat_col[2] = 0.0; } } else { mat_col[0] = 0.8; mat_col[1] = 0.2; mat_col[2] = 0.2; } glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col); TopLoc_Location loc; Handle(Geom_Surface) surf = BRep_Tool::Surface (face); BRepAdaptor_Surface sf(face, Standard_False); BRepLProp_SLProps prop(sf, 1, 1e-5); Handle(Poly_Triangulation) triangulation = BRep_Tool::Triangulation (face, loc); if (triangulation.IsNull()) { cout << "cannot visualize face " << i << endl; occgeometry->fvispar[i-1].SetNotDrawable(); continue; } gp_Pnt2d uv; gp_Pnt pnt; gp_Vec n; glBegin (GL_TRIANGLES); int ntriangles = triangulation -> NbTriangles(); for (int j = 1; j <= ntriangles; j++) { Poly_Triangle triangle = (triangulation -> Triangles())(j); gp_Pnt p[3]; for (int k = 1; k <= 3; k++) p[k-1] = (triangulation -> Nodes())(triangle(k)).Transformed(loc); for (int k = 1; k <= 3; k++) { uv = (triangulation -> UVNodes())(triangle(k)); prop.SetParameters (uv.X(), uv.Y()); // surf->D0 (uv.X(), uv.Y(), pnt); if (prop.IsNormalDefined()) n = prop.Normal(); else { (*testout) << "Visualization of face " << i << ": Normal vector not defined" << endl; // n = gp_Vec (0,0,0); gp_Vec a(p[0],p[1]); gp_Vec b(p[0],p[2]); n = b^a; } if (face.Orientation() == TopAbs_REVERSED) n *= -1; glNormal3f (n.X(), n.Y(), n.Z()); glVertex3f (p[k-1].X(), p[k-1].Y(), p[k-1].Z()); } } glEnd (); } glEndList (); } void SelectFaceInOCCDialogTree (int facenr); void VisualSceneOCCGeometry :: MouseDblClick (int px, int py) { int hits; // select surface triangle by mouse click GLuint selbuf[10000]; glSelectBuffer (10000, selbuf); glRenderMode (GL_SELECT); GLint viewport[4]; glGetIntegerv (GL_VIEWPORT, viewport); glMatrixMode (GL_PROJECTION); glPushMatrix(); GLdouble projmat[16]; glGetDoublev (GL_PROJECTION_MATRIX, projmat); glLoadIdentity(); gluPickMatrix (px, viewport[3] - py, 1, 1, viewport); glMultMatrixd (projmat); glClearColor(backcolor, backcolor, backcolor, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode (GL_MODELVIEW); glPushMatrix(); glMultMatrixf (transformationmat); glInitNames(); glPushName (1); glPolygonOffset (1, 1); glEnable (GL_POLYGON_OFFSET_FILL); glDisable(GL_CLIP_PLANE0); // Philippose - 30/01/2009 // Enable clipping planes for Selection mode in OCC Geometry if (vispar.clipenable) { Vec<3> n(clipplane[0], clipplane[1], clipplane[2]); double len = Abs(n); double mu = -clipplane[3] / (len*len); Point<3> p (mu * n); n /= len; Vec<3> t1 = n.GetNormal (); Vec<3> t2 = Cross (n, t1); double xi1mid = (center - p) * t1; double xi2mid = (center - p) * t2; glLoadName (0); glBegin (GL_QUADS); glVertex3dv (p + (xi1mid-rad) * t1 + (xi2mid-rad) * t2); glVertex3dv (p + (xi1mid+rad) * t1 + (xi2mid-rad) * t2); glVertex3dv (p + (xi1mid+rad) * t1 + (xi2mid+rad) * t2); glVertex3dv (p + (xi1mid-rad) * t1 + (xi2mid+rad) * t2); glEnd (); } glCallList (trilists.Get(1)); glDisable (GL_POLYGON_OFFSET_FILL); glPopName(); glMatrixMode (GL_PROJECTION); glPopMatrix(); glMatrixMode (GL_MODELVIEW); glPopMatrix(); glFlush(); hits = glRenderMode (GL_RENDER); int minname = 0; GLuint mindepth = 0; // find clippingplane GLuint clipdepth = 0; // GLuint(-1); for (int i = 0; i < hits; i++) { int curname = selbuf[4*i+3]; if (!curname) clipdepth = selbuf[4*i+1]; } for (int i = 0; i < hits; i++) { int curname = selbuf[4*i+3]; GLuint curdepth = selbuf[4*i+1]; if (curname && (curdepth> clipdepth) && (curdepth < mindepth || !minname)) { mindepth = curdepth; minname = curname; } } occgeometry->LowLightAll(); if (minname) { occgeometry->fvispar[minname-1].Highlight(); if (vispar.occzoomtohighlightedentity) occgeometry->changed = OCCGEOMETRYVISUALIZATIONFULLCHANGE; else occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE; cout << "Selected face: " << minname << endl; } else { occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE; } glDisable(GL_CLIP_PLANE0); SelectFaceInOCCDialogTree (minname); // Philippose - 30/01/2009 // Set the currently selected face in the array // for local face mesh size definition occgeometry->SetSelectedFace(minname); // selecttimestamp = NextTimeStamp(); } } #endif #endif // NOTCL netgen-4.9.13/libsrc/visualization/vssolution.cpp0000644000175000001440000043553711353214325017135 00000000000000#ifndef NOTCL #include #include "incvis.hpp" #include #include #include #include // #include #include namespace netgen { extern AutoPtr mesh; extern VisualSceneMesh vsmesh; VisualSceneSolution :: SolData :: SolData () : name (0), data (0), solclass(0) { ; } VisualSceneSolution :: SolData :: ~SolData () { delete [] name; delete data; delete solclass; } bool SolutionData :: GetMultiValue (int elnr, int npts, const double * xref, int sxref, const double * x, int sx, const double * dxdxref, int sdxdxref, double * values, int svalues) { bool res = false; for (int i = 0; i < npts; i++) res = GetValue (elnr, &xref[i*sxref], &x[i*sx], &dxdxref[i*sdxdxref], &values[i*svalues]); return res; } bool SolutionData :: GetMultiSurfValue (int selnr, int npts, const double * xref, int sxref, const double * x, int sx, const double * dxdxref, int sdxdxref, double * values, int svalues) { bool res = false; for (int i = 0; i < npts; i++) res = GetSurfValue (selnr, &xref[i*sxref], &x[i*sx], &dxdxref[i*sdxdxref], &values[i*svalues]); return res; } VisualSceneSolution :: VisualSceneSolution () : VisualScene() { surfellist = 0; linelist = 0; clipplanelist = 0; isolinelist = 0; clipplane_isolinelist = 0; surface_vector_list = 0; isosurface_list = 0; fieldlineslist = 0; pointcurvelist = 0; num_fieldlineslists = 0; surfeltimestamp = GetTimeStamp(); surfellinetimestamp = GetTimeStamp(); clipplanetimestamp = GetTimeStamp(); solutiontimestamp = GetTimeStamp(); fieldlinestimestamp = GetTimeStamp(); pointcurve_timestamp = GetTimeStamp(); surface_vector_timestamp = GetTimeStamp(); isosurface_timestamp = GetTimeStamp(); timetimestamp = GetTimeStamp(); AddVisualizationScene ("solution", &vssolution); } VisualSceneSolution :: ~VisualSceneSolution () { ClearSolutionData(); } void VisualSceneSolution :: AddSolutionData (SolData * sd) { NgLock meshlock1 (mesh->MajorMutex(), 1); int funcnr = -1; for (int i = 0; i < soldata.Size(); i++) { if (strcmp (soldata[i]->name, sd->name) == 0) { delete soldata[i]; soldata[i] = sd; funcnr = i; break; } } if (funcnr == -1) { soldata.Append (sd); funcnr = soldata.Size()-1; } SolData * nsd = soldata[funcnr]; nsd->size = 0; if (mesh) { switch (nsd->soltype) { case SOL_NODAL: nsd->size = mesh->GetNV(); break; case SOL_ELEMENT: nsd->size = mesh->GetNE(); break; case SOL_SURFACE_ELEMENT: nsd->size = mesh->GetNSE(); break; case SOL_NONCONTINUOUS: { switch (nsd->order) { case 0: nsd->size = mesh->GetNE(); break; case 1: nsd->size = 6 * mesh->GetNE(); break; case 2: nsd->size = 18 * mesh->GetNE(); break; } break; } case SOL_SURFACE_NONCONTINUOUS: { switch (nsd->order) { case 0: nsd->size = mesh->GetNSE(); break; case 1: nsd->size = 4 * mesh->GetNSE(); break; case 2: nsd->size = 9 * mesh->GetNSE(); break; } break; } default: nsd->size = 0; } solutiontimestamp = NextTimeStamp(); } } void VisualSceneSolution :: ClearSolutionData () { for (int i = 0; i < soldata.Size(); i++) delete soldata[i]; soldata.SetSize (0); } void VisualSceneSolution :: UpdateSolutionTimeStamp () { solutiontimestamp = NextTimeStamp(); } VisualSceneSolution::SolData * VisualSceneSolution :: GetSolData (int i) { if (i >= 0 && i < soldata.Size()) return soldata[i]; else return NULL; } void VisualSceneSolution :: SaveSolutionData (const char * filename) { PrintMessage (1, "Write solution data to file ", filename); if (strcmp (&filename[strlen(filename)-3], "sol") == 0) { ofstream ost(filename); for (int i = 0; i < soldata.Size(); i++) { const SolData & sol = *soldata[i]; ost << "solution " << sol.name << " -size=" << sol.size << " -components=" << sol.components << " -order=" << sol.order; if (sol.iscomplex) ost << " -complex"; switch (sol.soltype) { case SOL_NODAL: ost << " -type=nodal"; break; case SOL_ELEMENT: ost << " -type=element"; break; case SOL_SURFACE_ELEMENT: ost << " -type=surfaceelement"; break; case SOL_NONCONTINUOUS: ost << " -type=noncontinuous"; break; case SOL_SURFACE_NONCONTINUOUS: ost << " -type=surfacenoncontinuous"; break; default: cerr << "save solution data, case not handeld" << endl; } ost << endl; for (int j = 0; j < sol.size; j++) { for (int k = 0; k < sol.components; k++) ost << sol.data[j*sol.dist+k] << " "; ost << "\n"; } } } if (strcmp (&filename[strlen(filename)-3], "vtk") == 0) { string surf_fn = filename; surf_fn.erase (strlen(filename)-4); surf_fn += "_surf.vtk"; cout << "surface mesh = " << surf_fn << endl; ofstream surf_ost(surf_fn.c_str()); surf_ost << "# vtk DataFile Version 1.0\n" << "NGSolve surface mesh\n" << "ASCII\n" << "DATASET UNSTRUCTURED_GRID\n\n"; surf_ost << "POINTS " << mesh->GetNP() << " float\n"; for (PointIndex pi = PointIndex::BASE; pi < mesh->GetNP()+PointIndex::BASE; pi++) { const MeshPoint & mp = (*mesh)[pi]; surf_ost << mp(0) << " " << mp(1) << " " << mp(2) << "\n"; } int cntverts = 0; for (SurfaceElementIndex sei = 0; sei < mesh->GetNSE(); sei++) cntverts += 1 + (*mesh)[sei].GetNP(); surf_ost << "\nCELLS " << mesh->GetNSE() << " " << cntverts << "\n"; for (SurfaceElementIndex sei = 0; sei < mesh->GetNSE(); sei++) { const Element2d & el = (*mesh)[sei]; surf_ost << el.GetNP(); for (int j = 0; j < el.GetNP(); j++) surf_ost << " " << el[j] - PointIndex::BASE; surf_ost << "\n"; } surf_ost << "\nCELL_TYPES " << mesh->GetNSE() << "\n"; for (SurfaceElementIndex sei = 0; sei < mesh->GetNSE(); sei++) { const Element2d & el = (*mesh)[sei]; switch (el.GetType()) { case QUAD: surf_ost << 9; break; case TRIG: surf_ost << 5; break; default: cerr << "not implemented 2378" << endl; } surf_ost << "\n"; } ofstream ost(filename); ost << "# vtk DataFile Version 1.0\n" << "NGSolve solution\n" << "ASCII\n" << "DATASET UNSTRUCTURED_GRID\n\n"; ost << "POINTS " << mesh->GetNP() << " float\n"; for (PointIndex pi = PointIndex::BASE; pi < mesh->GetNP()+PointIndex::BASE; pi++) { const MeshPoint & mp = (*mesh)[pi]; ost << mp(0) << " " << mp(1) << " " << mp(2) << "\n"; } cntverts = 0; for (ElementIndex ei = 0; ei < mesh->GetNE(); ei++) cntverts += 1 + (*mesh)[ei].GetNP(); ost << "\nCELLS " << mesh->GetNE() << " " << cntverts << "\n"; for (ElementIndex ei = 0; ei < mesh->GetNE(); ei++) { const Element & el = (*mesh)[ei]; ost << el.GetNP(); for (int j = 0; j < el.GetNP(); j++) ost << " " << el[j] - PointIndex::BASE; ost << "\n"; } ost << "\nCELL_TYPES " << mesh->GetNE() << "\n"; for (ElementIndex ei = 0; ei < mesh->GetNE(); ei++) { const Element & el = (*mesh)[ei]; switch (el.GetType()) { case TET: ost << 10; break; default: cerr << "not implemented 67324" << endl; } ost << "\n"; } ost << "CELL_DATA " << mesh->GetNE() << "\n"; for (int i = 0; i < soldata.Size(); i++) { ost << "VECTORS bfield float\n"; SolutionData & sol = *(soldata[i] -> solclass); double values[3]; for (int elnr = 0; elnr < mesh->GetNE(); elnr++) { sol.GetValue (elnr, 0.25, 0.25, 0.25, values); ost << values[0] << " " << values[1] << " " << values[2] << "\n"; } } /* ost << "POINT_DATA " << mesh->GetNP() << "\n"; for (int i = 0; i < soldata.Size(); i++) { ost << "VECTORS bfield float\n"; SolutionData & sol = *(soldata[i] -> solclass); for (PointIndex pi = PointIndex::BASE; pi < mesh->GetNP()+PointIndex::BASE; pi++) { double values[3], sumvalues[3] = { 0, 0, 0 }; FlatArray els = mesh->GetTopology().GetVertexElements(pi); for (int j = 0; j < els.Size(); j++) { sol.GetValue (els[j]-1, 0.25, 0.25, 0.25, values); for (int k = 0; k < 3; k++) sumvalues[k] += values[k]; } for (int k = 0; k < 3; k++) sumvalues[k] /= els.Size(); ost << sumvalues[0] << " " << sumvalues[1] << " " << sumvalues[2] << "\n"; } } */ } } void VisualSceneSolution :: DrawScene () { clock_t starttime, endtime; starttime = clock(); if (!mesh) { VisualScene::DrawScene(); return; } // static NgLock mem_lock(mem_mutex); // mem_lock.Lock(); NgLock meshlock1 (mesh->MajorMutex(), true); NgLock meshlock (mesh->Mutex(), true); BuildScene(); CreateTexture (numtexturecols, lineartexture, GL_MODULATE); glClearColor(backcolor, backcolor, backcolor, 1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); SetLight(); glPushMatrix(); glMultMatrixf (transformationmat); glMatrixMode (GL_MODELVIEW); glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); glPolygonOffset (1, 1); glEnable (GL_POLYGON_OFFSET_FILL); glEnable (GL_COLOR_MATERIAL); if (usetexture) { SetTextureMode (usetexture); glMatrixMode (GL_TEXTURE); glLoadIdentity(); if (usetexture == 1) { double hmax = maxval; double hmin = minval; if (invcolor) Swap (hmax, hmin); if (fabs (hmax - hmin) > 1e-30) glScaled (1.0 / (hmin - hmax), 0, 0); else glScaled (1e30, 0, 0); glTranslatef (-hmax, 0, 0); } else { glTranslatef (0.5, 0, 0); glRotatef(360 * vssolution.time, 0, 0, -1); if (fabs (maxval) > 1e-10) glScalef(0.5/maxval, 0.5/maxval, 0.5/maxval); else glScalef (1e10, 1e10, 1e10); } glMatrixMode (GL_MODELVIEW); } if (vispar.drawfilledtrigs || vispar.drawtetsdomain > 0 || vispar.drawdomainsurf > 0) { SetClippingPlane (); glCallList (surfellist); glCallList (surface_vector_list); glDisable(GL_CLIP_PLANE0); } if (showclipsolution) glCallList (clipplanelist); if (draw_fieldlines) { SetClippingPlane(); if (num_fieldlineslists <= 1) glCallList (fieldlineslist); else { // animated int start = int (time / 10 * num_fieldlineslists); for (int ln = 0; ln < 10; ln++) { int nr = fieldlineslist + (start + ln) % num_fieldlineslists; glCallList (nr); } } glDisable(GL_CLIP_PLANE0); } if(drawpointcurves) { glCallList(pointcurvelist); } glMatrixMode (GL_TEXTURE); glLoadIdentity(); glMatrixMode (GL_MODELVIEW); glDisable (GL_TEXTURE_1D); glDisable (GL_TEXTURE_2D); glDisable (GL_POLYGON_OFFSET_FILL); glDisable (GL_COLOR_MATERIAL); if (draw_isosurface) glCallList (isosurface_list); GLfloat matcol0[] = { 0, 0, 0, 1 }; glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, matcol0); glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, matcol0); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, matcol0); glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); glLineWidth (1.0f); glColor3f (0.0f, 0.0f, 0.0f); glDisable (GL_LINE_SMOOTH); if (vispar.drawoutline && !numisolines) { SetClippingPlane (); glCallList (linelist); glDisable(GL_CLIP_PLANE0); } if (numisolines) { SetClippingPlane (); glCallList (isolinelist); glDisable(GL_CLIP_PLANE0); glCallList (clipplane_isolinelist); } glPopMatrix(); glDisable(GL_CLIP_PLANE0); DrawColorBar (minval, maxval, logscale, lineartexture); if (vispar.drawcoordinatecross) DrawCoordinateCross (); DrawNetgenLogo (); glFinish(); // delete lock; // mem_lock.UnLock(); endtime = clock(); // cout << 1.0 / (double(endtime - starttime)/CLOCKS_PER_SEC) << " frames/sec" << endl; } void VisualSceneSolution :: RealVec3d (const double * values, Vec3d & v, bool iscomplex, bool imag) { if (!iscomplex) { v.X() = values[0]; v.Y() = values[1]; v.Z() = values[2]; } else { if (!imag) { v.X() = values[0]; v.Y() = values[2]; v.Z() = values[4]; } else { v.X() = values[1]; v.Y() = values[3]; v.Z() = values[5]; } } } void VisualSceneSolution :: RealVec3d (const double * values, Vec3d & v, bool iscomplex, double phaser, double phasei) { if (!iscomplex) { v.X() = values[0]; v.Y() = values[1]; v.Z() = values[2]; } else { for (int i = 0; i < 3; i++) v.X(i+1) = phaser * values[2*i] + phasei * values[2*i+1]; } } void VisualSceneSolution :: BuildScene (int zoomall) { if (!mesh) { VisualScene::BuildScene (zoomall); return; } /* if (!cone_list) { cone_list = glGenLists (1); glNewList (cone_list, GL_COMPILE); DrawCone (Point<3> (0,0,0), Point<3> (0,0,1), 0.4); glEndList(); } */ // vispar.colormeshsize = 1; // recalc clipping plane SetClippingPlane (); glDisable(GL_CLIP_PLANE0); SolData * sol = NULL; SolData * vsol = NULL; if (scalfunction != -1) sol = soldata[scalfunction]; if (vecfunction != -1) vsol = soldata[vecfunction]; if (mesh->GetTimeStamp () > solutiontimestamp) { sol = NULL; vsol = NULL; } if (sol && sol->solclass) sol->solclass->SetMultiDimComponent (multidimcomponent); if (vsol && vsol->solclass) vsol->solclass->SetMultiDimComponent (multidimcomponent); if (!autoscale || (!sol && !vsol) ) { minval = mminval; maxval = mmaxval; } else { if (mesh->GetTimeStamp () > surfeltimestamp || vispar.clipplanetimestamp > clipplanetimestamp || solutiontimestamp > surfeltimestamp) { GetMinMax (scalfunction, scalcomp, minval, maxval); } } if (mesh->GetTimeStamp() > surfeltimestamp || solutiontimestamp > surfeltimestamp || zoomall) { if (mesh->GetTimeStamp() > surfeltimestamp || zoomall) { // mesh has changed Point3d pmin, pmax; static double oldrad = 0; mesh->GetBox (pmin, pmax, -1); center = Center (pmin, pmax); rad = 0.5 * Dist (pmin, pmax); glEnable (GL_NORMALIZE); if (rad > 1.5 * oldrad || mesh->GetMajorTimeStamp() > surfeltimestamp || zoomall) { CalcTransformationMatrices(); oldrad = rad; } } DrawSurfaceElements(); surfeltimestamp = max2 (solutiontimestamp, mesh->GetTimeStamp()); } if (mesh->GetTimeStamp() > surfellinetimestamp || subdivision_timestamp > surfellinetimestamp || (deform && solutiontimestamp > surfellinetimestamp) || zoomall) { if (linelist) glDeleteLists (linelist, 1); linelist = glGenLists (1); glNewList (linelist, GL_COMPILE); DrawSurfaceElementLines(); glEndList (); surfellinetimestamp = max2 (solutiontimestamp, mesh->GetTimeStamp()); } if (mesh->GetTimeStamp() > surface_vector_timestamp || solutiontimestamp > surface_vector_timestamp || zoomall) { if (surface_vector_list) glDeleteLists (surface_vector_list, 1); surface_vector_list = glGenLists (1); glNewList (surface_vector_list, GL_COMPILE); glEnable (GL_NORMALIZE); DrawSurfaceVectors(); glEndList (); surface_vector_timestamp = max2 (mesh->GetTimeStamp(), solutiontimestamp); } if (clipplanetimestamp < vispar.clipplanetimestamp || clipplanetimestamp < solutiontimestamp) { // cout << "clipsolution = " << clipsolution << endl; if (vispar.clipenable && clipsolution == 2) { // lock->UnLock(); NgLock mlock (mesh->Mutex(), 0); mlock.UnLock(); mesh->BuildElementSearchTree(); mlock.Lock(); // lock->Lock(); } if (clipplanelist) glDeleteLists (clipplanelist, 1); clipplanelist = glGenLists (1); glNewList (clipplanelist, GL_COMPILE); if (vispar.clipenable && clipsolution == 1 && sol) { glDisable(GL_CLIP_PLANE0); Array cpt; Array pts; GetClippingPlaneTrigs (cpt, pts); glNormal3d (-clipplane[0], -clipplane[1], -clipplane[2]); glColor3d (1.0, 1.0, 1.0); SetTextureMode (usetexture); DrawClipPlaneTrigs (sol, scalcomp, cpt, pts); glEnable(GL_CLIP_PLANE0); } if (vispar.clipenable && clipsolution == 2 && vsol) { SetTextureMode (usetexture); if (autoscale) GetMinMax (vecfunction, 0, minval, maxval); Array cpp; GetClippingPlaneGrid (cpp); for (int i = 0; i < cpp.Size(); i++) { const ClipPlanePoint & p = cpp[i]; double values[6]; Vec3d v; bool drawelem = GetValues (vsol, p.elnr, p.lami(0), p.lami(1), p.lami(2), values); RealVec3d (values, v, vsol->iscomplex, imag_part); double val = v.Length(); if (drawelem && val > 1e-10 * maxval) { v *= (rad / val / gridsize * 0.5); SetOpenGlColor (val); DrawCone (p.p, p.p+v, rad / gridsize * 0.2); } } } glEndList (); } if (mesh->GetTimeStamp() > isosurface_timestamp || solutiontimestamp > isosurface_timestamp || zoomall) { if (isosurface_list) glDeleteLists (isosurface_list, 1); isosurface_list = glGenLists (1); glNewList (isosurface_list, GL_COMPILE); glEnable (GL_NORMALIZE); DrawIsoSurface(sol, vsol, scalcomp); glEndList (); isosurface_timestamp = max2 (mesh->GetTimeStamp(), solutiontimestamp); } if(mesh->GetTimeStamp() > pointcurve_timestamp || solutiontimestamp > pointcurve_timestamp) { if(pointcurvelist) glDeleteLists(pointcurvelist,1); if(mesh->GetNumPointCurves() > 0) { pointcurvelist = glGenLists(1); glNewList(pointcurvelist,GL_COMPILE); //glColor3f (1.0f, 0.f, 0.f); for(int i=0; iGetNumPointCurves(); i++) { Box3d box; box.SetPoint(mesh->GetPointCurvePoint(i,0)); for(int j=1; jGetNumPointsOfPointCurve(i); j++) box.AddPoint(mesh->GetPointCurvePoint(i,j)); double diam = box.CalcDiam(); double thick = min2(0.1*diam, 0.001*rad); double red,green,blue; mesh->GetPointCurveColor(i,red,green,blue); glColor3f (red, green, blue); for(int j=0; jGetNumPointsOfPointCurve(i)-1; j++) { DrawCylinder(mesh->GetPointCurvePoint(i,j), mesh->GetPointCurvePoint(i,j+1), thick); } } glEndList(); } } if ( numisolines && (clipplanetimestamp < vispar.clipplanetimestamp || clipplanetimestamp < solutiontimestamp) ) { if (isolinelist) glDeleteLists (isolinelist, 1); isolinelist = glGenLists (1); glNewList (isolinelist, GL_COMPILE); Point<3> points[1100]; double values[1100]; int nse = mesh->GetNSE(); CurvedElements & curv = mesh->GetCurvedElements(); if (sol) { glBegin (GL_LINES); for (SurfaceElementIndex sei = 0; sei < nse; sei++) { const Element2d & el = (*mesh)[sei]; #ifdef PARALLEL // parallel visualization --> dont draw ghost elements if ( el . IsGhost() ) continue; #endif bool curved = curv.IsHighOrder(); // && curv.IsSurfaceElementCurved(sei); if (el.GetType() == TRIG || el.GetType() == TRIG6) { Point<3> lp1, lp2, lp3; if (!curved) { GetPointDeformation (el[0]-1, lp1); GetPointDeformation (el[1]-1, lp2); GetPointDeformation (el[2]-1, lp3); } int n = 1 << subdivisions; int ii = 0; int ix, iy; for (iy = 0; iy <= n; iy++) for (ix = 0; ix <= n-iy; ix++) { double x = double(ix) / n; double y = double(iy) / n; // TODO: consider return value (bool: draw/don't draw element) GetSurfValue (sol, sei, x, y, scalcomp, values[ii]); Point<2> xref(x,y); if (curved) mesh->GetCurvedElements(). CalcSurfaceTransformation (xref, sei, points[ii]); else points[ii] = lp3 + x * (lp1-lp3) + y * (lp2-lp3); if (deform) { points[ii] += GetSurfDeformation (sei, x, y); } ii++; } ii = 0; for (iy = 0; iy < n; iy++, ii++) for (ix = 0; ix < n-iy; ix++, ii++) { int index[] = { ii, ii+1, ii+n-iy+1, ii+1, ii+n-iy+2, ii+n-iy+1 }; DrawIsoLines (points[index[0]], points[index[1]], points[index[2]], values[index[0]], values[index[1]], values[index[2]]); // minval, maxval, numisolines); if (ix < n-iy-1) DrawIsoLines (points[index[3]], points[index[4]], points[index[5]], values[index[3]], values[index[4]], values[index[5]]); // minval, maxval, numisolines); } } if (el.GetType() == QUAD || el.GetType() == QUAD6 || el.GetType() == QUAD8 ) { Point<3> lpi[4]; Vec<3> vx, vy, vtwist, def; if (!curved) { for (int j = 0; j < 4; j++) GetPointDeformation (el[j]-1, lpi[j]); vx = lpi[1]-lpi[0]; vy = lpi[3]-lpi[0]; vtwist = (lpi[0]-lpi[1]) + (lpi[2]-lpi[3]); } int n = 1 << subdivisions; int ix, iy, ii = 0; for (iy = 0; iy <= n; iy++) for (ix = 0; ix <= n; ix++, ii++) { double x = double(ix) / n; double y = double(iy) / n; // TODO: consider return value (bool: draw/don't draw element) GetSurfValue (sol, sei, x, y, scalcomp, values[ii]); Point<2> xref(x,y); if (curved) mesh->GetCurvedElements(). CalcSurfaceTransformation (xref, sei, points[ii]); else points[ii] = lpi[0] + x * vx + y * vy + x*y * vtwist; if (deform) points[ii] += GetSurfDeformation (sei, x, y); } ii = 0; for (iy = 0; iy < n; iy++, ii++) for (ix = 0; ix < n; ix++, ii++) { DrawIsoLines (points[ii], points[ii+1], points[ii+n+1], values[ii], values[ii+1], values[ii+n+1]); // minval, maxval, numisolines); DrawIsoLines (points[ii+1], points[ii+n+2], points[ii+n+1], values[ii+1], values[ii+n+2], values[ii+n+1]); // minval, maxval, numisolines); } } } glEnd(); } glEndList (); if (clipplane_isolinelist) glDeleteLists (clipplane_isolinelist, 1); if (vispar.clipenable && clipsolution == 1 && sol) { clipplane_isolinelist = glGenLists (1); glNewList (clipplane_isolinelist, GL_COMPILE); Array cpt; Array pts; GetClippingPlaneTrigs (cpt, pts); bool drawelem; glNormal3d (-clipplane[0], -clipplane[1], -clipplane[2]); if (numisolines) for (int i = 0; i < cpt.Size(); i++) { const ClipPlaneTrig & trig = cpt[i]; double vali[3]; for (int j = 0; j < 3; j++) { Point<3> lami = pts[trig.points[j].pnr].lami; drawelem = GetValue (sol, trig.elnr, lami(0), lami(1), lami(2), scalcomp, vali[j]); } if ( drawelem ) DrawIsoLines (pts[trig.points[0].pnr].p, pts[trig.points[1].pnr].p, pts[trig.points[2].pnr].p, // trig.points[1].p, // trig.points[2].p, vali[0], vali[1], vali[2]); // , minval, maxval, numisolines); } glEndList (); } glEnd(); } clipplanetimestamp = max2 (vispar.clipplanetimestamp, solutiontimestamp); } void VisualSceneSolution :: DrawSurfaceElements () { static int timer = NgProfiler::CreateTimer ("Solution::DrawSurfaceElements"); NgProfiler::RegionTimer reg (timer); #ifdef PARALLELGL if (id == 0 && ntasks > 1) { InitParallelGL(); par_surfellists.SetSize (ntasks); for ( int dest = 1; dest < ntasks; dest++ ) { MyMPI_Send ("redraw", dest); MyMPI_Send ("solsurfellist", dest); } for ( int dest = 1; dest < ntasks; dest++ ) MyMPI_Recv (par_surfellists[dest], dest); if (surfellist) glDeleteLists (surfellist, 1); surfellist = glGenLists (1); glNewList (surfellist, GL_COMPILE); for ( int dest = 1; dest < ntasks; dest++ ) glCallList (par_surfellists[dest]); glEndList(); return; } #endif if (surfellist) glDeleteLists (surfellist, 1); surfellist = glGenLists (1); glNewList (surfellist, GL_COMPILE); const SolData * sol = NULL; const SolData * vsol = NULL; if (scalfunction != -1) sol = soldata[scalfunction]; if (vecfunction != -1) vsol = soldata[vecfunction]; if (mesh->GetTimeStamp () > solutiontimestamp) { sol = NULL; vsol = NULL; } glLineWidth (1.0f); GLfloat col_grey[] = { 0.6f, 0.6f, 0.6f }; glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, col_grey); int nse = mesh->GetNSE(); SetTextureMode (usetexture); CurvedElements & curv = mesh->GetCurvedElements(); int n = 1 << subdivisions; int npt = sqr(n+1); Array > pref (npt); Array > points (npt); Array > dxdxis (npt); Array > nvs(npt); Array values(npt); Array mvalues(npt); if (sol && sol->draw_surface) mvalues.SetSize (npt * sol->components); Array > valuesc(npt); for (SurfaceElementIndex sei = 0; sei < nse; sei++) { const Element2d & el = (*mesh)[sei]; if ( el . IsGhost() ) continue; if (vispar.drawdomainsurf > 0) { if (mesh->GetDimension() == 3) { if (vispar.drawdomainsurf != mesh->GetFaceDescriptor(el.GetIndex()).DomainIn() && vispar.drawdomainsurf != mesh->GetFaceDescriptor(el.GetIndex()).DomainOut()) continue; } else { if (el.GetIndex() != vispar.drawdomainsurf) continue; } } if ( el.GetType() == QUAD || el.GetType() == QUAD6 ) { bool curved = curv.IsSurfaceElementCurved (sei); Point<3> lpi[4]; Vec<3> vx, vy, vtwist; if (! curved) { for (int k = 0; k < 4; k++) GetPointDeformation (el[k]-1, lpi[k]); vx = lpi[1]-lpi[0]; vy = lpi[3]-lpi[0]; vtwist = (lpi[0]-lpi[1]) + (lpi[2]-lpi[3]); } // Vec<3> nv = Cross (lpi[1]-lpi[0], Center (lpi[2],lpi[3]) - lpi[0]); // nv.Normalize(); // glNormal3dv (nv); for (int iy = 0, ii = 0; iy <= n; iy++) for (int ix = 0; ix <= n; ix++, ii++) pref[ii] = Point<2> (double(ix)/n, double(iy)/n); int npt = (n+1)*(n+1); if (curved) for (int ii = 0; ii < npt; ii++) { Point<2> xref = pref[ii]; Mat<3,2> dxdxi; mesh->GetCurvedElements(). CalcSurfaceTransformation (xref, sei, points[ii], dxdxi); nvs[ii] = Cross (dxdxi.Col(0), dxdxi.Col(1)); nvs[ii].Normalize(); } else { for (int ii = 0; ii < npt; ii++) { double x = pref[ii](0); double y = pref[ii](1); points[ii] = lpi[0] + x * vx + y * vy + x*y * vtwist; } Vec<3> nv = Cross (vx, vy); nv.Normalize(); for (int ii = 0; ii < npt; ii++) nvs[ii] = nv; } bool drawelem = false; if (sol && sol->draw_surface) { if (usetexture == 2) for (int ii = 0; ii < npt; ii++) drawelem = GetSurfValueComplex (sol, sei, pref[ii](0), pref[ii](1), scalcomp, valuesc[ii]); else for (int ii = 0; ii < npt; ii++) drawelem = GetSurfValue (sol, sei, pref[ii](0), pref[ii](1), scalcomp, values[ii]); } if (deform) for (int ii = 0; ii < npt; ii++) points[ii] += GetSurfDeformation (sei, pref[ii](0), pref[ii](1)); int save_usetexture = usetexture; if (!drawelem) { usetexture = 0; SetTextureMode (0); } int ii = 0; glBegin (GL_QUADS); for (int iy = 0; iy < n; iy++, ii++) for (int ix = 0; ix < n; ix++, ii++) { int index[] = { ii, ii+1, ii+n+2, ii+n+1 }; for (int j = 0; j < 4; j++) { if (drawelem) { if (usetexture != 2) SetOpenGlColor (values[index[j]]); else glTexCoord2f ( valuesc[index[j]].real(), valuesc[index[j]].imag() ); } else glColor3fv (col_grey); glNormal3dv (nvs[index[j]]); glVertex3dv (points[index[j]]); } } glEnd(); if (!drawelem && (usetexture != save_usetexture)) { usetexture = save_usetexture; SetTextureMode (usetexture); } } } n = 1 << subdivisions; double invn = 1.0 / n; npt = (n+1)*(n+2)/2; for(SurfaceElementIndex sei = 0; sei < nse; sei++) { const Element2d & el = (*mesh)[sei]; if ( el . IsGhost() ) continue; if(vispar.drawdomainsurf > 0) { if (mesh->GetDimension() == 3) { if (vispar.drawdomainsurf != mesh->GetFaceDescriptor(el.GetIndex()).DomainIn() && vispar.drawdomainsurf != mesh->GetFaceDescriptor(el.GetIndex()).DomainOut()) continue; } else { if (el.GetIndex() != vispar.drawdomainsurf) continue; } } if ( el.GetType() == TRIG || el.GetType() == TRIG6 ) { bool curved = curv.IsSurfaceElementCurved(sei); for (int iy = 0, ii = 0; iy <= n; iy++) for (int ix = 0; ix <= n-iy; ix++, ii++) pref[ii] = Point<2> (ix*invn, iy*invn); if (curved) { mesh->GetCurvedElements(). CalcMultiPointSurfaceTransformation (&pref, sei, &points, &dxdxis); for (int ii = 0; ii < npt; ii++) nvs[ii] = Cross (dxdxis[ii].Col(0), dxdxis[ii].Col(1)).Normalize(); } else { Point<3> p1 = mesh->Point (el[0]); Point<3> p2 = mesh->Point (el[1]); Point<3> p3 = mesh->Point (el[2]); Vec<3> vx = p1-p3; Vec<3> vy = p2-p3; for (int ii = 0; ii < npt; ii++) { points[ii] = p3 + pref[ii](0) * vx + pref[ii](1) * vy; for (int j = 0; j < 3; j++) { dxdxis[ii](j,0) = vx(j); dxdxis[ii](j,1) = vy(j); } } Vec<3> nv = Cross (vx, vy).Normalize(); for (int ii = 0; ii < npt; ii++) nvs[ii] = nv; } bool drawelem = false; if (sol && sol->draw_surface) { drawelem = GetMultiSurfValues (sol, sei, npt, &pref[0](0), &pref[1](0)-&pref[0](0), &points[0](0), &points[1](0)-&points[0](0), &dxdxis[0](0), &dxdxis[1](0)-&dxdxis[0](0), &mvalues[0], sol->components); if (usetexture == 2) for (int ii = 0; ii < npt; ii++) valuesc[ii] = ExtractValueComplex(sol, scalcomp, &mvalues[ii*sol->components]); else for (int ii = 0; ii < npt; ii++) values[ii] = ExtractValue(sol, scalcomp, &mvalues[ii*sol->components]); } if (deform) for (int ii = 0; ii < npt; ii++) points[ii] += GetSurfDeformation (sei, pref[ii](0), pref[ii](1)); int save_usetexture = usetexture; if (!drawelem) { usetexture = 0; SetTextureMode (usetexture); } for (int iy = 0, ii = 0; iy < n; iy++) { glBegin (GL_TRIANGLE_STRIP); for (int ix = 0; ix <= n-iy; ix++, ii++) for (int k = 0; k < 2; k++) { if (ix+iy+k > n) continue; int hi = (k == 0) ? ii : ii+n-iy+1; if (drawelem) { if (usetexture != 2) SetOpenGlColor (values[hi]); else glTexCoord2f ( valuesc[hi].real(), valuesc[hi].imag() ); } else glColor3fv (col_grey); glNormal3dv (nvs[hi]); glVertex3dv (points[hi]); } glEnd(); } if (!drawelem && (usetexture != save_usetexture)) { usetexture = save_usetexture; SetTextureMode (usetexture); } } } glEndList (); #ifdef PARALLELGL glFinish(); if (id > 0) MyMPI_Send (surfellist, 0); #endif } void VisualSceneSolution :: DrawSurfaceElementLines () { glLineWidth (1.0f); // glNormal3d (1, 0, 0); int nse = mesh->GetNSE(); CurvedElements & curv = mesh->GetCurvedElements(); int n = 1 << subdivisions; ArrayMem, 65> ptsloc(n+1); ArrayMem, 65> ptsglob(n+1); double trigpts[3][2] = { { 0, 0 }, { 1, 0 }, { 0, 1} }; double trigvecs[3][2] = { { 1, 0 }, { -1,1 }, { 0, -1} }; double quadpts[4][2] = { { 0, 0 }, { 1, 0 }, { 1, 1 }, { 0, 1} }; double quadvecs[4][2] = { { 1, 0 }, { 0, 1 }, { -1, 0}, { 0, -1} }; for (SurfaceElementIndex sei = 0; sei < nse; sei++) { Element2d & el = (*mesh)[sei]; if ( el . IsGhost() ) continue; bool curved = curv.IsSurfaceElementCurved (sei); int nv = (el.GetType() == TRIG || el.GetType() == TRIG6) ? 3 : 4; Point<3> p1, p2, p3, p4; if (!curved) { p1 = (*mesh)[el[0]]; p2 = (*mesh)[el[1]]; p3 = (*mesh)[el[2]]; if (nv == 4) p4 = (*mesh)[el[3]]; } for (int k = 0; k < nv; k++) { Point<2> p0; Vec<2> vtau; if (nv == 3) { p0 = Point<2>(trigpts[k][0], trigpts[k][1]); vtau = Vec<2>(trigvecs[k][0], trigvecs[k][1]); } else { p0 = Point<2>(quadpts[k][0], quadpts[k][1]); vtau = Vec<2>(quadvecs[k][0], quadvecs[k][1]); } glBegin (GL_LINE_STRIP); if (curved) { for (int ix = 0; ix <= n; ix++) ptsloc[ix] = p0 + (double(ix) / n) * vtau; mesh->GetCurvedElements(). CalcMultiPointSurfaceTransformation (&ptsloc, sei, &ptsglob, 0); for (int ix = 0; ix <= n; ix++) { if (deform) ptsglob[ix] += GetSurfDeformation (sei, ptsloc[ix](0), ptsloc[ix](1)); glVertex3dv (ptsglob[ix]); } } else { for (int ix = 0; ix <= n; ix++) { Point<2> p = p0 + (double(ix) / n) * vtau; Point<3> pnt; if (nv == 3) pnt = p3 + p(0) * (p1-p3) + p(1) * (p2-p3); else pnt = p1 + p(0) * (p2-p1) + p(1) * (p4-p1) + p(0)*p(1) * ( (p1-p2)+(p3-p4) ); if (deform) pnt += GetSurfDeformation (sei, p(0), p(1) ); glVertex3dv (pnt); } } glEnd (); } } } void VisualSceneSolution :: DrawIsoSurface(const SolData * sol, const SolData * vsol, int comp) { if (!draw_isosurface) return; if (!sol) return; SetTextureMode (0); glColor3d (1.0, 0, 0); glEnable (GL_COLOR_MATERIAL); glBegin (GL_TRIANGLES); int ne = mesh->GetNE(); const int edgei[6][2] = { { 0, 1 }, { 0, 2 }, { 0, 3 }, { 1, 2 }, { 1, 3 }, { 2, 3 } }; double edgelam[6]; Point<3> edgep[6]; Vec<3> normp[6]; double nodevali[4]; int cntce; int cpe1 = 0, cpe2 = 0, cpe3 = 0; int n = 1 << subdivisions; int n3 = (n+1)*(n+1)*(n+1); Array > grid(n3); Array > locgrid(n3); Array > trans(n3); Array val(n3); Array > grads(n3); Array compress(n3); MatrixFixWidth<3> pointmat(8); grads = Vec<3> (0.0); for (ElementIndex ei = 0; ei < ne; ei++) { // if(vispar.clipdomain > 0 && vispar.clipdomain != (*mesh)[ei].GetIndex()) continue; // if(vispar.donotclipdomain > 0 && vispar.donotclipdomain == (*mesh)[ei].GetIndex()) continue; if ( (*mesh)[ei] . IsGhost() ) continue; ELEMENT_TYPE type = (*mesh)[ei].GetType(); if (type == HEX || type == PRISM || type == TET || type == PYRAMID) { const Element & el = (*mesh)[ei]; int ii = 0; int cnt_valid = 0; for (int ix = 0; ix <= n; ix++) for (int iy = 0; iy <= n; iy++) for (int iz = 0; iz <= n; iz++, ii++) { Point<3> ploc; compress[ii] = ii; switch (type) { case PRISM: if (ix+iy <= n) { ploc = Point<3> (double(ix) / n, double(iy) / n, double(iz) / n); compress[ii] = cnt_valid; cnt_valid++; } else compress[ii] = -1; break; case TET: if (ix+iy+iz <= n) { ploc = Point<3> (double(ix) / n, double(iy) / n, double(iz) / n); compress[ii] = cnt_valid; cnt_valid++; } else compress[ii] = -1; break; case HEX: ploc = Point<3> (double(ix) / n, double(iy) / n, double(iz) / n); break; case PYRAMID: ploc = Point<3> (double(ix) / n * (1-double(iz)/n), double(iy) / n * (1-double(iz)/n), double(iz)/n); break; default: cerr << "case not implementd 878234" << endl; ploc = 0.0; } if (compress[ii] != -1) locgrid[compress[ii]] = ploc; } if (type != TET && type != PRISM) cnt_valid = n3; if (mesh->GetCurvedElements().IsHighOrder() || 1) { mesh->GetCurvedElements(). CalcMultiPointElementTransformation (&locgrid, ei, &grid, &trans); } else { Vector shape(el.GetNP()); for (int k = 0; k < el.GetNP(); k++) for (int j = 0; j < 3; j++) pointmat(k,j) = (*mesh)[el[k]](j); for (int i = 0; i < cnt_valid; i++) { el.GetShapeNew (locgrid[i], shape); Point<3> pglob; for (int j = 0; j < 3; j++) { pglob(j) = 0; for (int k = 0; k < el.GetNP(); k++) pglob(j) += shape(k) * pointmat(k,j); } grid[i] = pglob; } } bool has_pos = 0, has_neg = 0; for (int i = 0; i < cnt_valid; i++) { GetValue (sol, ei, &locgrid[i](0), &grid[i](0), &trans[i](0), comp, val[i]); val[i] -= minval; if (vsol) GetValues (vsol, ei, &locgrid[i](0), &grid[i](0), &trans[i](0), &grads[i](0)); grads[i] *= -1; if (val[i] > 0) has_pos = 1; else has_neg = 1; } if (!has_pos || !has_neg) continue; for (int ix = 0; ix < n; ix++) for (int iy = 0; iy < n; iy++) for (int iz = 0; iz < n; iz++) { int base = iz + (n+1)*iy + (n+1)*(n+1)*ix; int pi[8] = { base, base+(n+1)*(n+1), base+(n+1)*(n+1)+(n+1), base+(n+1), base+1, base+(n+1)*(n+1)+1, base+(n+1)*(n+1)+(n+1)+1, base+(n+1)+1 }; for (int j = 0; j < 8; j++) pi[j] = compress[pi[j]]; int tets[6][4] = { { 1, 2, 4, 5 }, { 4, 5, 2, 8 }, { 2, 8, 5, 6 }, { 2, 3, 4, 8 }, { 2, 3, 8, 6 }, { 3, 8, 6, 7 } }; for (int ii = 0; ii < 6; ii++) { int teti[4]; for (int k = 0; k < 4; k++) teti[k] = pi[tets[ii][k]-1]; bool is_valid = 1; for (int j = 0; j < 4; j++) if (teti[j] == -1) is_valid = 0; if (!is_valid) continue; for (int j = 0; j < 4; j++) nodevali[j] = val[teti[j]]; cntce = 0; for (int j = 0; j < 6; j++) { int lpi1 = edgei[j][0]; int lpi2 = edgei[j][1]; if ( (nodevali[lpi1] > 0) != (nodevali[lpi2] > 0) ) { Point<3> p1 = grid[teti[lpi1]]; Point<3> p2 = grid[teti[lpi2]]; edgelam[j] = nodevali[lpi2] / (nodevali[lpi2] - nodevali[lpi1]); edgep[j] = grid[teti[lpi1]] + (1-edgelam[j]) * (grid[teti[lpi2]]-grid[teti[lpi1]]); normp[j] = grads[teti[lpi1]] + (1-edgelam[j]) * (grads[teti[lpi2]]-grads[teti[lpi1]]); cntce++; cpe3 = cpe2; cpe2 = cpe1; cpe1 = j; if (cntce >= 3) { if (!vsol) { Point<3> points[3]; points[0] = edgep[cpe1]; points[1] = edgep[cpe2]; points[2] = edgep[cpe3]; Vec<3> normal = Cross (points[2]-points[0], points[1]-points[0]); if ( ( (normal * (p2-p1)) > 0 ) == ( nodevali[lpi1] < 0) ) normal *= -1; glNormal3dv (normal); glVertex3dv (points[0]); glVertex3dv (points[1]); glVertex3dv (points[2]); } else { // glNormal3dv (grads[teti[0]]); glNormal3dv (normp[cpe1]); glVertex3dv (edgep[cpe1]); glNormal3dv (normp[cpe2]); glVertex3dv (edgep[cpe2]); glNormal3dv (normp[cpe3]); glVertex3dv (edgep[cpe3]); } } } } } } } } glEnd(); } void VisualSceneSolution :: DrawTrigSurfaceVectors(const Array< Point<3> > & lp, const Point<3> & pmin, const Point<3> & pmax, const int sei, const SolData * vsol) { int dir,dir1,dir2; double s,t; Vec<3> n = Cross (lp[1]-lp[0], lp[2]-lp[0]); Vec<3> na (fabs (n(0)), fabs(n(1)), fabs(n(2))); if (na(0) > na(1) && na(0) > na(2)) dir = 1; else if (na(1) > na(2)) dir = 2; else dir = 3; dir1 = (dir % 3) + 1; dir2 = (dir1 % 3) + 1; Point<2> p2d[3]; int k; for (k = 0; k < 3; k++) { p2d[k] = Point<2> ((lp[k](dir1-1) - pmin(dir1-1)) / (2*rad), (lp[k](dir2-1) - pmin(dir2-1)) / (2*rad)); } double minx2d, maxx2d, miny2d, maxy2d; minx2d = maxx2d = p2d[0](0); miny2d = maxy2d = p2d[0](1); for (k = 1; k < 3; k++) { minx2d = min2 (minx2d, p2d[k](0)); maxx2d = max2 (maxx2d, p2d[k](0)); miny2d = min2 (miny2d, p2d[k](1)); maxy2d = max2 (maxy2d, p2d[k](1)); } double mat11 = p2d[1](0) - p2d[0](0); double mat21 = p2d[1](1) - p2d[0](1); double mat12 = p2d[2](0) - p2d[0](0); double mat22 = p2d[2](1) - p2d[0](1); double det = mat11*mat22-mat21*mat12; double inv11 = mat22/det; double inv21 = -mat21/det; double inv12 = -mat12/det; double inv22 = mat11/det; // cout << "drawsurfacevectors. xoffset = " << xoffset << ", yoffset = "; // cout << yoffset << endl; for (s = xoffset/gridsize; s <= 1+xoffset/gridsize; s += 1.0 / gridsize) if (s >= minx2d && s <= maxx2d) for (t = yoffset/gridsize; t <= 1+yoffset/gridsize; t += 1.0 / gridsize) if (t >= miny2d && t <= maxy2d) { double lam1 = inv11 * (s - p2d[0](0)) + inv12 * (t-p2d[0](1)); double lam2 = inv21 * (s - p2d[0](0)) + inv22 * (t-p2d[0](1)); if (lam1 >= 0 && lam2 >= 0 && lam1+lam2 <= 1) { Point<3> cp; for (k = 0; k < 3; k++) cp(k) = lp[0](k) + lam1 * (lp[1](k)-lp[0](k)) + lam2 * (lp[2](k)-lp[0](k)); Vec<3> v; double values[6]; bool drawelem = GetSurfValues (vsol, sei, lam1, lam2, values); if (!vsol->iscomplex) for (k = 0; k < 3; k++) v(k) = values[k]; else { if (!imag_part) for (k = 0; k < 3; k++) v(k) = values[2*k]; else for (k = 0; k < 3; k++) v(k) = values[2*k+1]; } if (mesh->GetDimension() == 2) if ( (!vsol->iscomplex && vsol->components != 3) || (vsol->iscomplex && vsol->components != 6) ) v(2) = 0; double val = v.Length(); SetOpenGlColor (val); // (val, minval, maxval, logscale); // change JS if (val > 1e-10 * maxval) v *= (rad / val / gridsize * 0.5); else drawelem = 0; if ( drawelem ) DrawCone (cp, cp+4*v, 0.8*rad / gridsize); } } } void VisualSceneSolution :: DrawSurfaceVectors () { SurfaceElementIndex sei; const SolData * vsol = NULL; // bool drawelem; if (vecfunction != -1) vsol = soldata[vecfunction]; if (mesh->GetTimeStamp () > solutiontimestamp) vsol = NULL; if (!vsol) return; Point<3> pmin = center - Vec3d (rad, rad, rad); Point<3> pmax = center - Vec3d (rad, rad, rad); // glColor3d (1.0, 1.0, 1.0); // glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); if (vsol->draw_surface && showsurfacesolution) { int nse = mesh->GetNSE(); for (sei = 0; sei < nse; sei++) { const Element2d & el = (*mesh)[sei]; if ( el . IsGhost() ) continue; if (el.GetType() == TRIG || el.GetType() == TRIG6) { Array< Point<3> > lp(3); lp[0] = mesh->Point(el[2]); lp[1] = mesh->Point(el[0]); lp[2] = mesh->Point(el[1]); DrawTrigSurfaceVectors(lp,pmin,pmax,sei,vsol); /* Vec<3> n = Cross (lp[1]-lp[0], lp[2]-lp[0]); Vec<3> na (fabs (n(0)), fabs(n(1)), fabs(n(2))); if (na(0) > na(1) && na(0) > na(2)) dir = 1; else if (na(1) > na(2)) dir = 2; else dir = 3; dir1 = (dir % 3) + 1; dir2 = (dir1 % 3) + 1; for (k = 0; k < 3; k++) { p2d[k] = Point<2> ((lp[k](dir1-1) - pmin(dir1-1)) / (2*rad), (lp[k](dir2-1) - pmin(dir2-1)) / (2*rad)); } double minx2d, maxx2d, miny2d, maxy2d; minx2d = maxx2d = p2d[0](0); miny2d = maxy2d = p2d[0](1); for (k = 1; k < 3; k++) { minx2d = min2 (minx2d, p2d[k](0)); maxx2d = max2 (maxx2d, p2d[k](0)); miny2d = min2 (miny2d, p2d[k](1)); maxy2d = max2 (maxy2d, p2d[k](1)); } double mat11 = p2d[1](0) - p2d[0](0); double mat21 = p2d[1](1) - p2d[0](1); double mat12 = p2d[2](0) - p2d[0](0); double mat22 = p2d[2](1) - p2d[0](1); double det = mat11*mat22-mat21*mat12; double inv11 = mat22/det; double inv21 = -mat21/det; double inv12 = -mat12/det; double inv22 = mat11/det; // cout << "drawsurfacevectors. xoffset = " << xoffset << ", yoffset = "; // cout << yoffset << endl; for (s = xoffset/gridsize; s <= 1+xoffset/gridsize; s += 1.0 / gridsize) if (s >= minx2d && s <= maxx2d) for (t = yoffset/gridsize; t <= 1+yoffset/gridsize; t += 1.0 / gridsize) if (t >= miny2d && t <= maxy2d) { double lam1 = inv11 * (s - p2d[0](0)) + inv12 * (t-p2d[0](1)); double lam2 = inv21 * (s - p2d[0](0)) + inv22 * (t-p2d[0](1)); if (lam1 >= 0 && lam2 >= 0 && lam1+lam2 <= 1) { Point<3> cp; for (k = 0; k < 3; k++) cp(k) = lp[0](k) + lam1 * (lp[1](k)-lp[0](k)) + lam2 * (lp[2](k)-lp[0](k)); Vec<3> v; double values[6]; drawelem = GetSurfValues (vsol, sei, lam1, lam2, values); if (!vsol->iscomplex) for (k = 0; k < 3; k++) v(k) = values[k]; else { if (!imag_part) for (k = 0; k < 3; k++) v(k) = values[2*k]; else for (k = 0; k < 3; k++) v(k) = values[2*k+1]; } if (mesh->GetDimension() == 2) if ( (!vsol->iscomplex && vsol->components != 3) || (vsol->iscomplex && vsol->components != 6) ) v(2) = 0; double val = v.Length(); SetOpenGlColor (val, minval, maxval, logscale); if (val > 1e-10 * maxval) v *= (rad / val / gridsize * 0.5); else drawelem = 0; // "drawelem": added 07.04.2004 (FB) if ( drawelem ) DrawCone (cp, cp+4*v, 0.8*rad / gridsize); } } */ } else if (el.GetType() == QUAD) { /* Array < Point<3> > lp(3); lp[0] = mesh->Point(el[0]); lp[1] = mesh->Point(el[1]); lp[2] = mesh->Point(el[2]); DrawTrigSurfaceVectors(lp,pmin,pmax,sei,vsol); lp[0] = mesh->Point(el[0]); lp[1] = mesh->Point(el[2]); lp[2] = mesh->Point(el[3]); DrawTrigSurfaceVectors(lp,pmin,pmax,sei,vsol); */ Point<3> lp[4]; Point<2> p2d[4]; for (int k = 0; k < 4; k++) lp[k] = mesh->Point (el[k]); Vec<3> n = Cross (lp[1]-lp[0], lp[2]-lp[0]); Vec<3> na (fabs (n(0)), fabs(n(1)), fabs(n(2))); int dir, dir1, dir2; if (na(0) > na(1) && na(0) > na(2)) dir = 1; else if (na(1) > na(2)) dir = 2; else dir = 3; dir1 = (dir % 3) + 1; dir2 = (dir1 % 3) + 1; for (int k = 0; k < 4; k++) { p2d[k] = Point<2> ((lp[k](dir1-1) - pmin(dir1-1)) / (2*rad), (lp[k](dir2-1) - pmin(dir2-1)) / (2*rad)); } double minx2d, maxx2d, miny2d, maxy2d; minx2d = maxx2d = p2d[0](0); miny2d = maxy2d = p2d[0](1); for (int k = 1; k < 4; k++) { minx2d = min2 (minx2d, p2d[k](0)); maxx2d = max2 (maxx2d, p2d[k](0)); miny2d = min2 (miny2d, p2d[k](1)); maxy2d = max2 (maxy2d, p2d[k](1)); } for (double s = xoffset/gridsize; s <= 1+xoffset/gridsize; s += 1.0 / gridsize) if (s >= minx2d && s <= maxx2d) for (double t = yoffset/gridsize; t <= 1+yoffset/gridsize; t += 1.0 / gridsize) if (t >= miny2d && t <= maxy2d) { double lami[3]; Point3d p3d(2*rad*s+pmin(0), 2*rad*t+pmin(1),0); if (mesh->PointContainedIn2DElement (p3d, lami, sei+1)) { Point<3> cp = p3d; double lam1 = lami[0]; double lam2 = lami[1]; //for (k = 0; k < 3; k++) //cp(k) = lp[0](k) + //lam1 * (lp[1](k)-lp[0](k)) + //lam2 * (lp[2](k)-lp[0](k)); Vec<3> v; double values[6]; bool drawelem = GetSurfValues (vsol, sei, lam1, lam2, values); (*testout) << "sei " << sei << " lam1 " << lam1 << " lam2 " << lam2 << " drawelem " << drawelem << endl; if (!vsol->iscomplex) for (int k = 0; k < 3; k++) v(k) = values[k]; else { if (!imag_part) for (int k = 0; k < 3; k++) v(k) = values[2*k]; else for (int k = 0; k < 3; k++) v(k) = values[2*k+1]; } if (mesh->GetDimension() == 2) if ( (!vsol->iscomplex && vsol->components != 3) || (vsol->iscomplex && vsol->components != 6) ) v(2) = 0; double val = v.Length(); SetOpenGlColor (val); // , minval, maxval, logscale); july 09 (*testout) << "v " << v << endl; if (val > 1e-10 * maxval) v *= (rad / val / gridsize * 0.5); (*testout) << "v " << v << endl; if ( drawelem ) { DrawCone (cp, cp+4*v, 0.8*rad / gridsize); (*testout) << "cp " << cp << " rad " << rad << " gridsize " << gridsize << endl; } } } } } } } void VisualSceneSolution :: DrawIsoLines (const Point<3> & p1, const Point<3> & p2, const Point<3> & p3, double val1, double val2, double val3) { DrawIsoLines2 (p1, p2, p1, p3, val1, val2, val1, val3); // , minval, maxval, n); DrawIsoLines2 (p2, p1, p2, p3, val2, val1, val2, val3); // , minval, maxval, n); DrawIsoLines2 (p3, p1, p3, p2, val3, val1, val3, val2); // , minval, maxval, n); } void VisualSceneSolution :: DrawIsoLines2 (const Point<3> & hp1, const Point<3> & hp2, const Point<3> & hp3, const Point<3> & hp4, double val1, double val2, double val3, double val4) { int n = numisolines; Point<3> p1, p2, p3, p4; if (val1 < val2) { p1 = hp1; p2 = hp2; } else { p1 = hp2; p2 = hp1; swap (val1, val2); } if (val3 < val4) { p3 = hp3; p4 = hp4; } else { p3 = hp4; p4 = hp3; swap (val3, val4); } val2 += 1e-10; val4 += 1e-10; double fac = (maxval-minval) / n; double idelta1 = 1.0 / (val2 - val1); double idelta2 = 1.0 / (val4 - val3); int mini = int ((max2 (val1, val3) - minval) / fac); int maxi = int ((min2 (val2, val4) - minval) / fac); if (mini < 0) mini = 0; if (maxi > n-1) maxi = n-1; for (int i = mini; i <= maxi; i++) { double val = minval + i * fac; double lam1 = (val - val1) * idelta1; double lam2 = (val - val3) * idelta2; if (lam1 >= 0 && lam1 <= 1 && lam2 >= 0 && lam2 <= 1) { Point<3> lp1 = p1 + lam1 * (p2-p1); Point<3> lp2 = p3 + lam2 * (p4-p3); glVertex3dv (lp1 ); glVertex3dv (lp2 ); // glVertex3dv (lp2 ); // better ? // glVertex3dv (lp1 ); } } } void VisualSceneSolution :: GetMinMax (int funcnr, int comp, double & minv, double & maxv) const { const SolData * sol; double val; bool considerElem; bool hasit = false; minv = 0; maxv = 1; if (funcnr != -1) { sol = soldata[funcnr]; if (sol->draw_volume) { int ne = mesh->GetNE(); for (int i = 0; i < ne; i++) { considerElem = GetValue (sol, i, 0.333, 0.333, 0.333, comp, val); if (considerElem) { if (val > maxv || !hasit) maxv = val; if (val < minv || !hasit) minv = val; hasit = true; } } } if (sol->draw_surface) { int nse = mesh->GetNSE(); for (int i = 0; i < nse; i++) { ELEMENT_TYPE type = mesh->SurfaceElement(i+1).GetType(); if (type == QUAD) considerElem = GetSurfValue (sol, i, 0.5, 0.5, comp, val); else considerElem = GetSurfValue (sol, i, 0.3333333, 0.3333333, comp, val); if (considerElem) { if (val > maxv || !hasit) maxv = val; if (val < minv || !hasit) minv = val; hasit = true; } } } } if (minv == maxv) maxv = minv+1e-6; } bool VisualSceneSolution :: GetValues (const SolData * data, ElementIndex elnr, double lam1, double lam2, double lam3, double * values) const { bool ok = false; switch (data->soltype) { case SOL_VIRTUALFUNCTION: { ok = data->solclass->GetValue (elnr, lam1, lam2, lam3, values); break; } default: { for (int i = 0; i < data->components; i++) ok = GetValue (data, elnr, lam1, lam2, lam3, i+1, values[i]); } } return ok; } bool VisualSceneSolution :: GetValues (const SolData * data, ElementIndex elnr, const double xref[], const double x[], const double dxdxref[], double * values) const { bool ok = false; switch (data->soltype) { case SOL_VIRTUALFUNCTION: { ok = data->solclass->GetValue (elnr, xref, x, dxdxref, values); break; } default: { for (int i = 0; i < data->components; i++) ok = GetValue (data, elnr, xref[0], xref[1], xref[2], i+1, values[i]); } } return ok; } bool VisualSceneSolution :: GetValue (const SolData * data, ElementIndex elnr, const double xref[], const double x[], const double dxdxref[], int comp, double & val) const { double lam1 = xref[0]; double lam2 = xref[1]; double lam3 = xref[2]; val = 0; bool ok = 0; if (comp == 0) { ArrayMem values(data->components); ok = GetValues (data, elnr, xref, x, dxdxref, &values[0]); switch (evalfunc) { case FUNC_ABS: { for (int ci = 0; ci < data->components; ci++) val += sqr (values[ci]); val = sqrt (val); break; } case FUNC_ABS_TENSOR: { int d = 0; switch (data->components) { case 1: d = 1; break; case 3: d = 2; break; case 6: d = 3; break; } int ci; for (ci = 0; ci < d; ci++) val += sqr (values[ci]); for (ci = d; ci < data->components; ci++) val += 2*sqr (values[ci]); val = sqrt (val); break; } case FUNC_MISES: { int d = 0; switch(data->components) { case 1: d = 1; break; case 3: d = 2; break; case 6: d = 3; break; } int ci; double trace = 0.; for (ci = 0; ci < d; ci++) trace += 1./3.*(values[ci]); for (ci = 0; ci < d; ci++) val += sqr (values[ci]-trace); for (ci = d; ci < data->components; ci++) val += 2.*sqr (values[ci]); val = sqrt (val); break; } case FUNC_MAIN: { int d = 0; switch(data->components) { case 1: d = 1; break; case 3: d = 2; break; case 6: d = 3; break; } Mat<3,3> m ; Vec<3> ev; int ci; for (ci = 0; ci < d; ci++) m(ci,ci) = (values[ci]); m(0,1) = m(1,0) = values[3]; m(0,2) = m(2,0) = values[4]; m(1,2) = m(2,1) = values[5]; EigenValues (m, ev); double help; for (int i=0; i abs(ev(j-1)) ) { help = ev(j); ev(j) = ev(j-1); ev(j-1) = help; } } } val = (ev(0)); break; } } return ok; } switch (data->soltype) { case SOL_VIRTUALFUNCTION: { double values[20]; ok = data->solclass->GetValue (elnr, xref, x, dxdxref, values); val = values[comp-1]; return ok; } case SOL_NODAL: { const Element & el = (*mesh)[elnr]; double lami[8] = { 0.0 }; int np = 0; switch (el.GetType()) { case TET: case TET10: { lami[1] = lam1; lami[2] = lam2; lami[3] = lam3; lami[0] = 1-lam1-lam2-lam3; np = 4; break; } case PRISM: case PRISM12: { lami[0] = (1-lam3) * (1-lam1-lam2); lami[1] = (1-lam3) * lam1; lami[2] = (1-lam3) * lam2; lami[3] = (lam3) * (1-lam1-lam2); lami[4] = (lam3) * lam1; lami[5] = (lam3) * lam2; np = 6; break; } default: cerr << "case not implementd 23523" << endl; } for (int i = 0; i < np; i++) val += lami[i] * data->data[(el[i]-1) * data->dist + comp-1]; return 1; } case SOL_ELEMENT: { val = data->data[elnr * data->dist + comp-1]; return 1; } case SOL_SURFACE_ELEMENT: return 0; case SOL_NONCONTINUOUS: { const Element & el = (*mesh)[elnr]; double lami[8] = { 0.0 }; int np = 0; switch (el.GetType()) { case TET: case TET10: { lami[1] = lam1; lami[2] = lam2; lami[3] = lam3; lami[0] = 1-lam1-lam2-lam3; np = 4; break; } case PRISM: case PRISM12: { lami[0] = (1-lam3) * (1-lam1-lam2); lami[1] = (1-lam3) * lam1; lami[2] = (1-lam3) * lam2; lami[3] = (lam3) * (1-lam1-lam2); lami[4] = (lam3) * lam1; lami[5] = (lam3) * lam2; np = 6; break; } case PYRAMID: { if (lam3 > 1-1e-5) { lami[0] = lami[1] = lami[2] = lami[3] = 0; lami[4] = 1; } else { double x0 = lam1 / (1-lam3); double y0 = lam2 / (1-lam3); lami[0] = (1-x0) * (1-y0) * (1-lam3); lami[1] = ( x0) * (1-y0) * (1-lam3); lami[2] = ( x0) * ( y0) * (1-lam3); lami[3] = (1-x0) * ( y0) * (1-lam3); lami[4] = lam3; np = 5; } break; } default: np = 0; } int base; if (data->order == 1) base = 6 * elnr; else base = 10 * elnr; for (int i = 0; i < np; i++) val += lami[i] * data->data[(base+i) * data->dist + comp-1]; return 1; } case SOL_MARKED_ELEMENTS: { val = (*mesh)[elnr].TestRefinementFlag(); return 1; } case SOL_ELEMENT_ORDER: { val = (*mesh)[elnr].GetOrder(); return 1; } default: cerr << "case not handled 7234" << endl; } return 0; } bool VisualSceneSolution :: GetValue (const SolData * data, ElementIndex elnr, double lam1, double lam2, double lam3, int comp, double & val) const { val = 0; bool ok = 0; if (comp == 0) { ArrayMem values(data->components); ok = GetValues (data, elnr, lam1, lam2, lam3, &values[0]); switch (evalfunc) { case FUNC_ABS: { for (int ci = 0; ci < data->components; ci++) val += sqr (values[ci]); val = sqrt (val); break; } case FUNC_ABS_TENSOR: { int d = 0; switch (data->components) { case 1: d = 1; break; case 3: d = 2; break; case 6: d = 3; break; } int ci; for (ci = 0; ci < d; ci++) val += sqr (values[ci]); for (ci = d; ci < data->components; ci++) val += 2*sqr (values[ci]); val = sqrt (val); break; } case FUNC_MISES: { int d = 0; switch(data->components) { case 1: d = 1; break; case 3: d = 2; break; case 6: d = 3; break; } int ci; double trace = 0.; for (ci = 0; ci < d; ci++) trace += 1./3.*(values[ci]); for (ci = 0; ci < d; ci++) val += sqr (values[ci]-trace); for (ci = d; ci < data->components; ci++) val += 2.*sqr (values[ci]); val = sqrt (val); break; } case FUNC_MAIN: { int d = 0; switch(data->components) { case 1: d = 1; break; case 3: d = 2; break; case 6: d = 3; break; } Mat<3,3> m ; Vec<3> ev; int ci; for (ci = 0; ci < d; ci++) m(ci,ci) = (values[ci]); m(0,1) = m(1,0) = values[3]; m(0,2) = m(2,0) = values[4]; m(1,2) = m(2,1) = values[5]; EigenValues (m, ev); double help; for (int i=0; i abs(ev(j-1)) ) { help = ev(j); ev(j) = ev(j-1); ev(j-1) = help; } } } val = (ev(0)); break; } } return ok; } switch (data->soltype) { case SOL_VIRTUALFUNCTION: { double values[20]; ok = data->solclass->GetValue (elnr, lam1, lam2, lam3, values); val = values[comp-1]; return ok; } case SOL_NODAL: { const Element & el = (*mesh)[elnr]; double lami[8] = { 0.0 }; int np = 0; switch (el.GetType()) { case TET: case TET10: { lami[1] = lam1; lami[2] = lam2; lami[3] = lam3; lami[0] = 1-lam1-lam2-lam3; np = 4; break; } case PRISM: case PRISM12: { lami[0] = (1-lam3) * (1-lam1-lam2); lami[1] = (1-lam3) * lam1; lami[2] = (1-lam3) * lam2; lami[3] = (lam3) * (1-lam1-lam2); lami[4] = (lam3) * lam1; lami[5] = (lam3) * lam2; np = 6; break; } default: cerr << "case not implemented 234324" << endl; } for (int i = 0; i < np; i++) val += lami[i] * data->data[(el[i]-1) * data->dist + comp-1]; return 1; } case SOL_ELEMENT: { val = data->data[elnr * data->dist + comp-1]; return 1; } case SOL_SURFACE_ELEMENT: return 0; case SOL_NONCONTINUOUS: { const Element & el = (*mesh)[elnr]; double lami[8] = { 0.0 }; int np = 0; switch (el.GetType()) { case TET: case TET10: { lami[1] = lam1; lami[2] = lam2; lami[3] = lam3; lami[0] = 1-lam1-lam2-lam3; np = 4; break; } case PRISM: case PRISM12: { lami[0] = (1-lam3) * (1-lam1-lam2); lami[1] = (1-lam3) * lam1; lami[2] = (1-lam3) * lam2; lami[3] = (lam3) * (1-lam1-lam2); lami[4] = (lam3) * lam1; lami[5] = (lam3) * lam2; np = 6; break; } case PYRAMID: { if (lam3 > 1-1e-5) { lami[0] = lami[1] = lami[2] = lami[3] = 0; lami[4] = 1; } else { double x0 = lam1 / (1-lam3); double y0 = lam2 / (1-lam3); lami[0] = (1-x0) * (1-y0) * (1-lam3); lami[1] = ( x0) * (1-y0) * (1-lam3); lami[2] = ( x0) * ( y0) * (1-lam3); lami[3] = (1-x0) * ( y0) * (1-lam3); lami[4] = lam3; np = 5; } break; } default: np = 0; } int base; if (data->order == 1) base = 6 * elnr; else base = 10 * elnr; for (int i = 0; i < np; i++) val += lami[i] * data->data[(base+i) * data->dist + comp-1]; return 1; } case SOL_MARKED_ELEMENTS: { val = (*mesh)[elnr].TestRefinementFlag(); return 1; } case SOL_ELEMENT_ORDER: { val = (*mesh)[elnr].GetOrder(); return 1; } default: cerr << "case not implemented 234234" << endl; } return 0; } bool VisualSceneSolution :: GetValueComplex (const SolData * data, ElementIndex elnr, double lam1, double lam2, double lam3, int comp, complex & val) const { val = 0.0; bool ok = 0; switch (data->soltype) { case SOL_VIRTUALFUNCTION: { double values[20]; ok = data->solclass->GetValue (elnr, lam1, lam2, lam3, values); val = complex (values[comp-1], values[comp]); return ok; } default: cerr << "case not handled 234234" << endl; } return 0; } bool VisualSceneSolution :: GetMultiValues (const SolData * data, ElementIndex elnr, int npt, const double * xref, int sxref, const double * x, int sx, const double * dxdxref, int sdxdxref, double * val, int sval) const { bool drawelem = false; if (data->soltype == SOL_VIRTUALFUNCTION) drawelem = data->solclass->GetMultiValue(elnr, npt, xref, sxref, x, sx, dxdxref, sdxdxref, val, sval); else for (int i = 0; i < npt; i++) drawelem = GetValues (data, elnr, xref+i*sxref, x+i*sx, dxdxref+i*sdxdxref, val+i*sval); return drawelem; } bool VisualSceneSolution :: GetSurfValues (const SolData * data, SurfaceElementIndex selnr, double lam1, double lam2, double * values) const { bool ok = false; switch (data->soltype) { case SOL_VIRTUALFUNCTION: { ok = data->solclass->GetSurfValue (selnr, lam1, lam2, values); // ok = 1; // values[0] = 1.0; break; } default: { for (int i = 0; i < data->components; i++) ok = GetSurfValue (data, selnr, lam1, lam2, i+1, values[i]); } } return ok; } bool VisualSceneSolution :: GetSurfValues (const SolData * data, SurfaceElementIndex selnr, const double xref[], const double x[], const double dxdxref[], double * values) const { bool ok = false; switch (data->soltype) { case SOL_VIRTUALFUNCTION: { ok = data->solclass->GetSurfValue (selnr, xref, x, dxdxref, values); break; } default: { for (int i = 0; i < data->components; i++) ok = GetSurfValue (data, selnr, xref[0], xref[1], i+1, values[i]); } } return ok; } bool VisualSceneSolution :: GetMultiSurfValues (const SolData * data, SurfaceElementIndex elnr, int npt, const double * xref, int sxref, const double * x, int sx, const double * dxdxref, int sdxdxref, double * val, int sval) const { bool drawelem = false; if (data->soltype == SOL_VIRTUALFUNCTION) drawelem = data->solclass->GetMultiSurfValue(elnr, npt, xref, sxref, x, sx, dxdxref, sdxdxref, val, sval); else for (int i = 0; i < npt; i++) drawelem = GetSurfValues (data, elnr, xref+i*sxref, x+i*sx, dxdxref+i*sdxdxref, val+i*sval); return drawelem; } double VisualSceneSolution :: ExtractValue (const SolData * data, int comp, double * values) const { double val = 0; if (comp == 0) { switch (evalfunc) { case FUNC_ABS: { for (int ci = 0; ci < data->components; ci++) val += sqr (values[ci]); val = sqrt (val); break; } case FUNC_ABS_TENSOR: { int d = 0; switch (data->components) { case 1: d = 1; break; case 3: d = 2; break; case 6: d = 3; break; } for (int ci = 0; ci < d; ci++) val += sqr (values[ci]); for (int ci = d; ci < data->components; ci++) val += 2*sqr (values[ci]); val = sqrt (val); break; } case FUNC_MISES: { int d = 0; switch(data->components) { case 1: d = 1; break; case 3: d = 2; break; case 6: d = 3; break; } int ci; double trace = 0.; for (ci = 0; ci < d; ci++) trace += 1./3.*(values[ci]); for (ci = 0; ci < d; ci++) val += sqr (values[ci]-trace); for (ci = d; ci < data->components; ci++) val += 2.*sqr (values[ci]); val = sqrt (val); break; } case FUNC_MAIN: { int d = 0; switch(data->components) { case 1: d = 1; break; case 3: d = 2; break; case 6: d = 3; break; } Mat<3,3> m ; Vec<3> ev; int ci; for (ci = 0; ci < d; ci++) m(ci,ci) = (values[ci]); m(0,1) = m(1,0) = values[3]; m(0,2) = m(2,0) = values[4]; m(1,2) = m(2,1) = values[5]; EigenValues (m, ev); double help; for (int i=0; i abs(ev(j-1)) ) { help = ev(j); ev(j) = ev(j-1); ev(j-1) = help; } } } val = (ev(0)); break; } } return val; } return values[comp-1]; } complex VisualSceneSolution :: ExtractValueComplex (const SolData * data, int comp, double * values) const { if (!data->iscomplex) return values[comp-1]; else return complex (values[comp-1], values[comp]); } bool VisualSceneSolution :: GetSurfValueComplex (const SolData * data, SurfaceElementIndex selnr, double lam1, double lam2, int comp, complex & val) const { switch (data->soltype) { case SOL_VIRTUALFUNCTION: { ArrayMem values(data->components); bool ok; ok = data->solclass->GetSurfValue (selnr, lam1, lam2, &values[0]); if (ok) { if (!data->iscomplex) val = values[comp-1]; else val = complex (values[comp-1], values[comp]); } return ok; } default: cerr << "case not implementd 6565" << endl; } return 0; } bool VisualSceneSolution :: GetSurfValue (const SolData * data, SurfaceElementIndex selnr, double lam1, double lam2, int comp, double & val) const { bool ok; if (comp == 0) { val = 0; ArrayMem values(data->components); ok = GetSurfValues (data, selnr, lam1, lam2, &values[0]); // ok = 1; // values[0] = 1.0; switch (evalfunc) { case FUNC_ABS: { for (int ci = 0; ci < data->components; ci++) val += sqr (values[ci]); val = sqrt (val); break; } case FUNC_ABS_TENSOR: { int d = 0; switch (data->components) { case 1: d = 1; break; case 3: d = 2; break; case 6: d = 3; break; } int ci; for (ci = 0; ci < d; ci++) val += sqr (values[ci]); for (ci = d; ci < data->components; ci++) val += 2*sqr (values[ci]); val = sqrt (val); break; } case FUNC_MISES: { int d = 0; switch(data->components) { case 1: d = 1; break; case 3: d = 2; break; case 6: d = 3; break; } int ci; double trace = 0.; for (ci = 0; ci < d; ci++) trace += 1./3.*(values[ci]); for (ci = 0; ci < d; ci++) val += sqr (values[ci]-trace); for (ci = d; ci < data->components; ci++) val += 2.*sqr (values[ci]); val = sqrt (val); break; } case FUNC_MAIN: { int d = 0; switch(data->components) { case 1: d = 1; break; case 3: d = 2; break; case 6: d = 3; break; } Mat<3,3> m ; Vec<3> ev; int ci; for (ci = 0; ci < d; ci++) m(ci,ci) = (values[ci]); m(0,1) = m(1,0) = values[3]; m(0,2) = m(2,0) = values[4]; m(1,2) = m(2,1) = values[5]; EigenValues (m, ev); double help; for (int i=0; i abs(ev(j-1)) ) { help = ev(j); ev(j) = ev(j-1); ev(j-1) = help; } } } val = (ev(0)); break; } } return ok; /* int ci; double val = 0; for (ci = 1; ci <= data->components; ci++) val += sqr (GetSurfValue (data, selnr, lam1, lam2, ci)); return sqrt (val); */ } switch (data->soltype) { case SOL_VIRTUALFUNCTION: { ArrayMem values(data->components); bool ok; ok = data->solclass->GetSurfValue (selnr, lam1, lam2, &values[0]); if (ok) { if (!data->iscomplex) val = values[comp-1]; else { // cout << "time = " << time << ", cos = " << cos(time) << endl; // old version: val = values[comp-1]*cos(3*time) + values[comp]*sin(3*time); // SZ: Sept 06 if(comp%2==0) val = values[comp-1]*cos(3*time) - values[comp-2]*sin(3*time); else val = values[comp-1]*cos(3*time) + values[comp]*sin(3*time); } } return ok; } case SOL_NODAL: { const Element2d & el = (*mesh)[selnr]; double lami[8]; int np, i; val = 0; double lam3 = 1-lam1-lam2; switch (el.GetType()) { case TRIG: /* lami[0] = lam3; lami[1] = lam1; lami[2] = lam2; */ lami[0] = lam1; lami[1] = lam2; lami[2] = lam3; np = 3; break; case TRIG6: /* lami[0] = lam3*(2*lam3-1); lami[1] = lam1*(2*lam1-1); lami[2] = lam2*(2*lam2-1); */ // hierarchical basis: lami[0] = lam3; lami[1] = lam1; lami[2] = lam2; lami[3] = 4*lam1*lam2; lami[4] = 4*lam2*lam3; lami[5] = 4*lam1*lam3; np = 6; break; case QUAD: case QUAD6: lami[0] = (1-lam1)*(1-lam2); lami[1] = lam1 * (1-lam2); lami[2] = lam1 * lam2; lami[3] = (1-lam1) * lam2; np = 4; break; default: np = 0; } for (i = 0; i < np; i++) val += lami[i] * data->data[(el[i]-1) * data->dist + comp-1]; return 1; } case SOL_ELEMENT: { int el1, el2; mesh->GetTopology().GetSurface2VolumeElement (selnr+1, el1, el2); el1--; val = data->data[el1 * data->dist+comp-1]; return 1; } case SOL_NONCONTINUOUS: { val = 0; // ????? return 0; } case SOL_SURFACE_ELEMENT: { val = data->data[selnr * data->dist + comp-1]; return 1; } case SOL_SURFACE_NONCONTINUOUS: { const Element2d & el = (*mesh)[selnr]; double lami[8]; int np = 0; val = 0; int order = data->order; switch (order) { case 0: return data->data[selnr * data->dist + comp-1]; case 1: { switch (el.GetType()) { case TRIG: case TRIG6: { lami[1] = lam1; lami[2] = lam2; lami[0] = 1-lam1-lam2; np = 3; break; } default: cerr << "case not implementd 2342" << endl; } break; } case 2: { switch (el.GetType()) { case TRIG: { lami[1] = lam1; lami[2] = lam2; lami[0] = 1-lam1-lam2; np = 3; break; } case TRIG6: { double lam3 = 1-lam1-lam2; lami[1] = 2*lam1 * (lam1-0.5); lami[2] = 2*lam2 * (lam2-0.5); lami[0] = 2*lam3 * (lam3-0.5); lami[3] = 4*lam1*lam2; lami[4] = 4*lam2*lam3; lami[5] = 4*lam1*lam3; np = 6; break; } default: cerr << "case not implemented 8712" << endl; } break; } } int base; if (order == 1) base = 4 * selnr; else base = 9 * selnr; for (int i = 0; i < np; i++) val += lami[i] * data->data[(base+i) * data->dist + comp-1]; return 1; } case SOL_MARKED_ELEMENTS: { val = (*mesh)[selnr].TestRefinementFlag(); return 1; } case SOL_ELEMENT_ORDER: { val = (*mesh)[selnr].GetOrder(); return 1; } } return 0; } bool VisualSceneSolution :: GetSurfValue (const SolData * data, SurfaceElementIndex selnr, const double xref[], const double x[], const double dxdxref[], int comp, double & val) const { double lam1 = xref[0], lam2 = xref[1]; bool ok; if (comp == 0) { val = 0; ArrayMem values(data->components); ok = GetSurfValues (data, selnr, xref, x, dxdxref, &values[0]); switch (evalfunc) { case FUNC_ABS: { for (int ci = 0; ci < data->components; ci++) val += sqr (values[ci]); val = sqrt (val); break; } case FUNC_ABS_TENSOR: { int d = 0; switch (data->components) { case 1: d = 1; break; case 3: d = 2; break; case 6: d = 3; break; } int ci; for (ci = 0; ci < d; ci++) val += sqr (values[ci]); for (ci = d; ci < data->components; ci++) val += 2*sqr (values[ci]); val = sqrt (val); break; } case FUNC_MISES: { int d = 0; switch(data->components) { case 1: d = 1; break; case 3: d = 2; break; case 6: d = 3; break; } int ci; double trace = 0.; for (ci = 0; ci < d; ci++) trace += 1./3.*(values[ci]); for (ci = 0; ci < d; ci++) val += sqr (values[ci]-trace); for (ci = d; ci < data->components; ci++) val += 2.*sqr (values[ci]); val = sqrt (val); break; } case FUNC_MAIN: { int d = 0; switch(data->components) { case 1: d = 1; break; case 3: d = 2; break; case 6: d = 3; break; } Mat<3,3> m ; Vec<3> ev; int ci; for (ci = 0; ci < d; ci++) m(ci,ci) = (values[ci]); m(0,1) = m(1,0) = values[3]; m(0,2) = m(2,0) = values[4]; m(1,2) = m(2,1) = values[5]; EigenValues (m, ev); double help; for (int i=0; i abs(ev(j-1)) ) { help = ev(j); ev(j) = ev(j-1); ev(j-1) = help; } } } val = (ev(0)); break; } } return ok; /* int ci; double val = 0; for (ci = 1; ci <= data->components; ci++) val += sqr (GetSurfValue (data, selnr, lam1, lam2, ci)); return sqrt (val); */ } switch (data->soltype) { case SOL_VIRTUALFUNCTION: { ArrayMem values(data->components); bool ok; // ok = data->solclass->GetSurfValue (selnr, lam1, lam2, &values[0]); // cout << "data->solclass = " << flush << data->solclass << endl; ok = data->solclass->GetSurfValue (selnr, xref, x, dxdxref, &values[0]); // ok = 1; // values[0] = 1.0; if (ok) { if (!data->iscomplex) val = values[comp-1]; else { // cout << "time = " << time << ", cos = " << cos(time) << endl; // old version: val = values[comp-1]*cos(3*time) + values[comp]*sin(3*time); // SZ: Sept 06 if(comp%2==0) val = values[comp-1]*cos(3*time) - values[comp-2]*sin(3*time); else val = values[comp-1]*cos(3*time) + values[comp]*sin(3*time); } } return ok; } case SOL_NODAL: { const Element2d & el = (*mesh)[selnr]; double lami[8]; int np, i; val = 0; double lam3 = 1-lam1-lam2; switch (el.GetType()) { case TRIG: /* lami[0] = lam3; lami[1] = lam1; lami[2] = lam2; */ lami[0] = lam1; lami[1] = lam2; lami[2] = lam3; np = 3; break; case TRIG6: /* lami[0] = lam3*(2*lam3-1); lami[1] = lam1*(2*lam1-1); lami[2] = lam2*(2*lam2-1); */ // hierarchical basis: lami[0] = lam3; lami[1] = lam1; lami[2] = lam2; lami[3] = 4*lam1*lam2; lami[4] = 4*lam2*lam3; lami[5] = 4*lam1*lam3; np = 6; break; case QUAD: case QUAD6: lami[0] = (1-lam1)*(1-lam2); lami[1] = lam1 * (1-lam2); lami[2] = lam1 * lam2; lami[3] = (1-lam1) * lam2; np = 4; break; default: np = 0; } for (i = 0; i < np; i++) val += lami[i] * data->data[(el[i]-1) * data->dist + comp-1]; return 1; } case SOL_ELEMENT: { int el1, el2; mesh->GetTopology().GetSurface2VolumeElement (selnr+1, el1, el2); el1--; val = data->data[el1 * data->dist+comp-1]; return 1; } case SOL_NONCONTINUOUS: { val = 0; // ????? return 0; } case SOL_SURFACE_ELEMENT: { val = data->data[selnr * data->dist + comp-1]; return 1; } case SOL_SURFACE_NONCONTINUOUS: { const Element2d & el = (*mesh)[selnr]; double lami[8] = { 0.0 }; int np = 0; val = 0; int order = data->order; switch (order) { case 0: return data->data[selnr * data->dist + comp-1]; case 1: { switch (el.GetType()) { case TRIG: case TRIG6: { lami[1] = lam1; lami[2] = lam2; lami[0] = 1-lam1-lam2; np = 3; break; } default: cerr << "case not impl 234234" << endl; } break; } case 2: { switch (el.GetType()) { case TRIG: { lami[1] = lam1; lami[2] = lam2; lami[0] = 1-lam1-lam2; np = 3; break; } case TRIG6: { double lam3 = 1-lam1-lam2; lami[1] = 2*lam1 * (lam1-0.5); lami[2] = 2*lam2 * (lam2-0.5); lami[0] = 2*lam3 * (lam3-0.5); lami[3] = 4*lam1*lam2; lami[4] = 4*lam2*lam3; lami[5] = 4*lam1*lam3; np = 6; break; } default: cerr << "case not implented 3234" << endl; } break; } } int base; if (order == 1) base = 4 * selnr; else base = 9 * selnr; for (int i = 0; i < np; i++) val += lami[i] * data->data[(base+i) * data->dist + comp-1]; return 1; } case SOL_MARKED_ELEMENTS: { val = (*mesh)[selnr].TestRefinementFlag(); return 1; } case SOL_ELEMENT_ORDER: { val = (*mesh)[selnr].GetOrder(); return 1; } } return 0; } Vec<3> VisualSceneSolution :: GetDeformation (ElementIndex elnr, const Point<3> & p) const { Vec<3> def; if (deform && vecfunction != -1) { GetValues (soldata[vecfunction], elnr, p(0), p(1), p(2), &def(0)); def *= scaledeform; if (soldata[vecfunction]->components == 2) def(2) = 0; } else def = 0; return def; } Vec<3> VisualSceneSolution :: GetSurfDeformation (SurfaceElementIndex elnr, double lam1, double lam2) const { Vec<3> def; if (deform && vecfunction != -1) { GetSurfValues (soldata[vecfunction], elnr, lam1, lam2, &def(0)); def *= scaledeform; if (soldata[vecfunction]->components == 2) def(2) = 0; } else if (deform && scalfunction != -1 && mesh->GetDimension()==2) { // he: allow for 3d plots of 2d surfaces: usage: turn deformation on def = 0; GetSurfValue (soldata[scalfunction], elnr, lam1, lam2, scalcomp, def(2)); def *= scaledeform; } else def = 0; return def; } void VisualSceneSolution :: GetPointDeformation (int pnum, Point<3> & p, SurfaceElementIndex elnr) const { p = mesh->Point (pnum+1); if (deform && vecfunction != -1) { const SolData * vsol = soldata[vecfunction]; Vec<3> v(0,0,0); if (vsol->soltype == SOL_NODAL) { v = Vec3d(vsol->data[pnum * vsol->dist], vsol->data[pnum * vsol->dist+1], vsol->data[pnum * vsol->dist+2]); } else if (vsol->soltype == SOL_SURFACE_NONCONTINUOUS) { const Element2d & el = (*mesh)[elnr]; for (int j = 0; j < el.GetNP(); j++) if (el[j] == pnum+1) { int base = (4*elnr+j-1) * vsol->dist; v = Vec3d(vsol->data[base], vsol->data[base+1], vsol->data[base+2]); } } if (vsol->dist == 2) v(2) = 0; v *= scaledeform; p += v; } } void VisualSceneSolution :: GetClippingPlaneTrigs (Array & trigs, Array & pts) { static int timer1 = NgProfiler::CreateTimer ("ClipPlaneTrigs1"); static int timer2 = NgProfiler::CreateTimer ("ClipPlaneTrigs2"); static int timer3 = NgProfiler::CreateTimer ("ClipPlaneTrigs3"); static int timer4 = NgProfiler::CreateTimer ("ClipPlaneTrigs4"); NgProfiler::RegionTimer reg1 (timer1); int ne = mesh->GetNE(); const int edgei[6][2] = { { 0, 1 }, { 0, 2 }, { 0, 3 }, { 1, 2 }, { 1, 3 }, { 2, 3 } }; double edgelam[6]; Point<3> edgep[6]; double nodevali[4]; int cntce; int cpe1 = 0, cpe2 = 0, cpe3 = 0; // Array loctets; // Array loctetsloc; // Array > pointsloc; int n = 1 << subdivisions; int n3 = (n+1)*(n+1)*(n+1); Array > grid(n3); Array > locgrid(n3); Array > trans(n3); Array val(n3); Array compress(n3); for (ElementIndex ei = 0; ei < ne; ei++) { int first_point_of_element = pts.Size(); #ifdef PARALLEL // parallel visualization --> dont draw ghost elements if ( (*mesh)[ei] . IsGhost() ) continue; #endif locgrid.SetSize(n3); if(vispar.clipdomain > 0 && vispar.clipdomain != (*mesh)[ei].GetIndex()) continue; if(vispar.donotclipdomain > 0 && vispar.donotclipdomain == (*mesh)[ei].GetIndex()) continue; ELEMENT_TYPE type = (*mesh)[ei].GetType(); if (type == HEX || type == PRISM || type == TET || type == TET10 || type == PYRAMID) { const Element & el = (*mesh)[ei]; int ii = 0; int cnt_valid = 0; NgProfiler::StartTimer (timer2); if (type == TET || type == TET10) { for (int ix = 0; ix <= n; ix++) for (int iy = 0; iy <= n; iy++) for (int iz = 0; iz <= n; iz++, ii++) { if (ix+iy+iz <= n) { compress[ii] = cnt_valid; locgrid[cnt_valid] = Point<3> (double(ix) / n, double(iy) / n, double(iz) / n); cnt_valid++; } else compress[ii] = -1; } } else for (int ix = 0; ix <= n; ix++) for (int iy = 0; iy <= n; iy++) for (int iz = 0; iz <= n; iz++, ii++) { Point<3> ploc; compress[ii] = ii; switch (type) { case PRISM: if (ix+iy <= n) { ploc = Point<3> (double(ix) / n, double(iy) / n, double(iz) / n); compress[ii] = cnt_valid; cnt_valid++; } else compress[ii] = -1; break; case HEX: ploc = Point<3> (double(ix) / n, double(iy) / n, double(iz) / n); break; case PYRAMID: ploc = Point<3> (double(ix) / n * (1-double(iz)/n), double(iy) / n * (1-double(iz)/n), double(iz)/n); if (iz == n) ploc = Point<3> (0,0,1-1e-8); break; default: cerr << "clip plane trigs not implemented" << endl; ploc = Point<3> (0,0,0); } if (compress[ii] != -1) locgrid[compress[ii]] = ploc; } if (type != TET && type != TET10 && type != PRISM) cnt_valid = n3; locgrid.SetSize(cnt_valid); NgProfiler::StopTimer (timer2); NgProfiler::RegionTimer reg4(timer4); if (mesh->GetCurvedElements().IsHighOrder()) { mesh->GetCurvedElements(). CalcMultiPointElementTransformation (&locgrid, ei, &grid, 0); } else { Vector shape(el.GetNP()); MatrixFixWidth<3> pointmat(el.GetNP()); for (int k = 0; k < el.GetNP(); k++) for (int j = 0; j < 3; j++) pointmat(k,j) = (*mesh)[el[k]](j); for (int i = 0; i < cnt_valid; i++) { el.GetShapeNew (locgrid[i], shape); Point<3> pglob; for (int j = 0; j < 3; j++) { pglob(j) = 0; for (int k = 0; k < el.GetNP(); k++) pglob(j) += shape(k) * pointmat(k,j); } grid[i] = pglob; } } NgProfiler::RegionTimer reg3(timer3); bool has_pos = 0, has_neg = 0; for (int i = 0; i < cnt_valid; i++) { val[i] = grid[i](0) * clipplane[0] + grid[i](1) * clipplane[1] + grid[i](2) * clipplane[2] + clipplane[3]; if (val[i] > 0) has_pos = 1; else has_neg = 1; } if (!has_pos || !has_neg) continue; for (int ix = 0; ix < n; ix++) for (int iy = 0; iy < n; iy++) for (int iz = 0; iz < n; iz++) { int base = iz + (n+1)*iy + (n+1)*(n+1)*ix; int pi[8] = { base, base+(n+1)*(n+1), base+(n+1)*(n+1)+(n+1), base+(n+1), base+1, base+(n+1)*(n+1)+1, base+(n+1)*(n+1)+(n+1)+1, base+(n+1)+1 }; for (int j = 0; j < 8; j++) pi[j] = compress[pi[j]]; const int tets[6][4] = { { 1, 2, 4, 5 }, { 4, 5, 2, 8 }, { 2, 8, 5, 6 }, { 2, 3, 4, 8 }, { 2, 3, 8, 6 }, { 3, 8, 6, 7 } }; for (int ii = 0; ii < 6; ii++) { int teti[4]; for (int k = 0; k < 4; k++) teti[k] = pi[tets[ii][k]-1]; bool is_valid = 1; for (int j = 0; j < 4; j++) if (teti[j] == -1) is_valid = 0; if (!is_valid) continue; for (int j = 0; j < 4; j++) nodevali[j] = val[teti[j]]; cntce = 0; for (int j = 0; j < 6; j++) { int lpi1 = edgei[j][0]; int lpi2 = edgei[j][1]; if ( (nodevali[lpi1] > 0) != (nodevali[lpi2] > 0) ) { edgelam[j] = nodevali[lpi2] / (nodevali[lpi2] - nodevali[lpi1]); Point<3> p1 = grid[teti[lpi1]]; Point<3> p2 = grid[teti[lpi2]]; edgep[j] = p1 + (1-edgelam[j]) * (p2-p1); cntce++; cpe3 = cpe2; cpe2 = cpe1; cpe1 = j; if (cntce >= 3) { ClipPlaneTrig cpt; cpt.elnr = ei; for (int k = 0; k < 3; k++) { int ednr; switch (k) { case 0: ednr = cpe1; break; case 1: ednr = cpe2; break; case 2: ednr = cpe3; break; } // cpt.points[k].p = edgep[ednr]; int pi1 = edgei[ednr][0]; int pi2 = edgei[ednr][1]; Point<3> p1 = locgrid[teti[pi1]]; Point<3> p2 = locgrid[teti[pi2]]; // cpt.points[k].lami = p2 + edgelam[ednr] * (p1-p2); ClipPlanePoint cppt; cppt.elnr = ei; cppt.p = edgep[ednr]; cppt.lami = p2 + edgelam[ednr] * (p1-p2); int pnr = -1; for (int l = first_point_of_element; l < pts.Size(); l++) if (fabs (cppt.lami(0)-pts[l].lami(0)) < 1e-8 && fabs (cppt.lami(1)-pts[l].lami(1)) < 1e-8 && fabs (cppt.lami(2)-pts[l].lami(2)) < 1e-8) { pnr = l; break; } if (pnr == -1) pnr = pts.Append (cppt)-1; cpt.points[k].pnr = pnr; cpt.points[k].locpnr = pnr-first_point_of_element; } trigs.Append (cpt); } } } } } } else { // other elements not supported (JS, June 2007) return; } } } void VisualSceneSolution :: GetClippingPlaneGrid (Array & pts) { Vec3d n(clipplane[0], clipplane[1], clipplane[2]); double mu = -clipplane[3] / n.Length2(); Point3d p(mu*n.X(), mu * n.Y(), mu * n.Z()); // n /= n.Length(); n.Normalize(); Vec3d t1, t2; n.GetNormal (t1); t2 = Cross (n, t1); double xi1, xi2; double xi1mid = (center - p) * t1; double xi2mid = (center - p) * t2; pts.SetSize(0); for (xi1 = xi1mid-rad+xoffset/gridsize; xi1 <= xi1mid+rad+xoffset/gridsize; xi1 += rad / gridsize) for (xi2 = xi2mid-rad+yoffset/gridsize; xi2 <= xi2mid+rad+yoffset/gridsize; xi2 += rad / gridsize) { Point3d hp = p + xi1 * t1 + xi2 * t2; int cindex(-1); bool allowindex(true); if(vispar.clipdomain > 0) { cindex = vispar.clipdomain; } else if(vispar.donotclipdomain > 0) { allowindex = false; cindex = vispar.donotclipdomain; } double lami[3]; int elnr = mesh->GetElementOfPoint (hp, lami,0,cindex,allowindex)-1; if (elnr != -1) { ClipPlanePoint cpp; cpp.p = hp; cpp.elnr = elnr; cpp.lami(0) = lami[0]; cpp.lami(1) = lami[1]; cpp.lami(2) = lami[2]; pts.Append (cpp); } } }; void VisualSceneSolution :: DrawClipPlaneTrigs (const SolData * sol, int comp, const Array & trigs, const Array & points) { glBegin (GL_TRIANGLES); int maxlpnr = 0; for (int i = 0; i < trigs.Size(); i++) for (int j = 0; j < 3; j++) maxlpnr = max2 (maxlpnr, trigs[i].points[j].locpnr); Array vals(maxlpnr+1); Array > valsc(maxlpnr+1); Array elnrs(maxlpnr+1); Array trigok(maxlpnr+1); Array > locpoints(maxlpnr+1); Array > globpoints(maxlpnr+1); Array > jacobi(maxlpnr+1); Array mvalues( (maxlpnr+1) * sol->components); trigok = false; elnrs = -1; Point<3> p[3]; // double val[3]; complex valc[3]; int lastelnr = -1; int nlp = -1; for (int i = 0; i < trigs.Size(); i++) { bool ok = true; const ClipPlaneTrig & trig = trigs[i]; if (trig.elnr != lastelnr) { lastelnr = trig.elnr; nlp = -1; for (int ii = i; ii < trigs.Size(); ii++) { if (trigs[ii].elnr != trig.elnr) break; for (int j = 0; j < 3; j++) nlp = max (nlp, trigs[ii].points[j].locpnr); } nlp++; locpoints.SetSize (nlp); for (int ii = i; ii < trigs.Size(); ii++) { if (trigs[ii].elnr != trig.elnr) break; for (int j = 0; j < 3; j++) locpoints[trigs[ii].points[j].locpnr] = points[trigs[ii].points[j].pnr].lami; } mesh->GetCurvedElements(). CalcMultiPointElementTransformation (&locpoints, trig.elnr, &globpoints, &jacobi); bool drawelem = GetMultiValues (sol, trig.elnr, nlp, &locpoints[0](0), &locpoints[1](0)-&locpoints[0](0), &globpoints[0](0), &globpoints[1](0)-&globpoints[0](0), &jacobi[0](0), &jacobi[1](0)-&jacobi[0](0), &mvalues[0], sol->components); if (!drawelem) ok = false; if (usetexture == 2) { ; // for (int ii = 0; ii < nlp; ii++) // valuesc[ii] = ExtractValueComplex(sol, scalcomp, &mvalues[ii*sol->components]); } else for (int ii = 0; ii < nlp; ii++) vals[ii] = ExtractValue(sol, scalcomp, &mvalues[ii*sol->components]); } for (int j = 0; ok && j < 3; j++) { p[j] = points[trig.points[j].pnr].p; Point<3> ploc = points[trig.points[j].pnr].lami; int locpnr = trig.points[j].locpnr; if (deform) p[j] += GetDeformation (trig.elnr, ploc); if (usetexture != 2 || !sol->iscomplex) { ; /* if (elnrs[trig.points[j].locpnr] != trig.elnr) { elnrs[trig.points[j].locpnr] = trig.elnr; ok = GetValue (sol, trig.elnr, &locpoints[locpnr](0), &globpoints[locpnr](0), &jacobi[locpnr](0,0), scalcomp, vals[locpnr]); trigok[trig.points[j].locpnr] = ok; } else { ok = trigok[trig.points[j].locpnr]; } */ } else { ok = GetValueComplex (sol, trig.elnr, ploc(0), ploc(1), ploc(2), scalcomp, valc[j]); } } if(ok) for(int j=0; j<3; j++) { if (usetexture != 2 || !sol->iscomplex) SetOpenGlColor (vals[trig.points[j].locpnr]); else glTexCoord2f ( valc[j].real(), valc[j].imag() ); glVertex3dv (p[j]); } } glEnd(); } void VisualSceneSolution :: SetOpenGlColor(double val) { if (usetexture == 1 && !logscale) { glTexCoord1f ( val ); return; } double valmin = minval; double valmax = maxval; double value; if (!logscale) value = (val - valmin) / (valmax - valmin); else { if (valmax <= 0) valmax = 1; if (valmin <= 0) valmin = 1e-4 * valmax; value = (log(fabs(val)) - log(valmin)) / (log(valmax) - log(valmin)); } if (!invcolor) value = 1 - value; if (value > 1) value = 1; if (value < 0) value = 0; value *= 4; static const double colp[][3] = { { 1, 0, 0 }, { 1, 1, 0 }, { 0, 1, 0 }, { 0, 1, 1 }, { 0, 0, 1 }, { 1, 0, 1 }, { 1, 0, 0 }, }; int i = int(value); double r = value - i; GLdouble col[3]; for (int j = 0; j < 3; j++) col[j] = (1-r) * colp[i][j] + r * colp[i+1][j]; glColor3dv (col); } void VisualSceneSolution :: SetTextureMode (int texturemode) const { switch (texturemode) { case 0: glDisable (GL_TEXTURE_1D); glDisable (GL_TEXTURE_2D); break; case 1: glEnable (GL_TEXTURE_1D); glDisable (GL_TEXTURE_2D); glColor3d (1.0, 1.0, 1.0); break; case 2: glDisable (GL_TEXTURE_1D); glEnable (GL_TEXTURE_2D); glColor3d (1.0, 1.0, 1.0); break; } } void VisualSceneSolution :: DrawCone (const Point<3> & p1, const Point<3> & p2, double r) { int n = 10, i; Vec<3> p1p2 = p2 - p1; p1p2.Normalize(); Vec<3> p2p1 = -p1p2; Vec<3> t1 = p1p2.GetNormal(); Vec<3> t2 = Cross (p1p2, t1); Point<3> oldp = p1 + r * t1; Vec<3> oldn = t1; Point<3> p; Vec<3> normal; Mat<2> rotmat; Vec<2> cs, newcs; cs(0) = 1; cs(1) = 0; rotmat(0,0) = rotmat(1,1) = cos(2*M_PI/n); rotmat(1,0) = sin(2*M_PI/n); rotmat(0,1) = -rotmat(1,0); glBegin (GL_TRIANGLES); for (i = 1; i <= n; i++) { /* phi = 2 * M_PI * i / n; normal = cos(phi) * t1 + sin(phi) * t2; */ newcs = rotmat * cs; cs = newcs; normal = cs(0) * t1 + cs(1) * t2; p = p1 + r * normal; // cone glNormal3dv (normal); glVertex3dv (p); glVertex3dv (p2); glNormal3dv (oldn); glVertex3dv (oldp); // base-circle glNormal3dv (p2p1); glVertex3dv (p); glVertex3dv (p1); glVertex3dv (oldp); oldp = p; oldn = normal; } glEnd (); } void VisualSceneSolution :: DrawCylinder (const Point<3> & p1, const Point<3> & p2, double r) { int n = 10, i; Vec<3> p1p2 = p2 - p1; p1p2.Normalize(); Vec<3> p2p1 = -p1p2; Vec<3> t1 = p1p2.GetNormal(); Vec<3> t2 = Cross (p1p2, t1); Point<3> oldhp1 = p1 + r * t1; Point<3> oldhp2 = p2 + r * t1; Vec<3> oldn = t1; Point<3> hp1, hp2; Vec<3> normal; Mat<2> rotmat; Vec<2> cs, newcs; cs(0) = 1; cs(1) = 0; rotmat(0,0) = rotmat(1,1) = cos(2*M_PI/n); rotmat(1,0) = sin(2*M_PI/n); rotmat(0,1) = -rotmat(1,0); glBegin (GL_QUADS); for (i = 1; i <= n; i++) { newcs = rotmat * cs; cs = newcs; normal = cs(0) * t1 + cs(1) * t2; hp1 = p1 + r * normal; hp2 = p2 + r * normal; // cylinder glNormal3dv (normal); glVertex3dv (hp1); glVertex3dv (hp2); glVertex3dv (oldhp2); glVertex3dv (oldhp1); oldhp1 = hp1; oldhp2 = hp2; oldn = normal; } glEnd (); } void VisualSceneSolution :: MouseDblClick (int px, int py) { vsmesh.SetClippingPlane(); vsmesh.BuildFilledList(); vsmesh.MouseDblClick(px,py); } #ifdef PARALLELGL void VisualSceneSolution :: Broadcast () { MyMPI_Bcast (usetexture); MyMPI_Bcast (clipsolution); MyMPI_Bcast (scalfunction); MyMPI_Bcast (scalcomp); MyMPI_Bcast (vecfunction); MyMPI_Bcast (gridsize); MyMPI_Bcast (autoscale); MyMPI_Bcast (logscale); MyMPI_Bcast (minval); MyMPI_Bcast (maxval); MyMPI_Bcast (numisolines); MyMPI_Bcast (subdivisions); } #endif int Ng_Vis_Set (ClientData clientData, Tcl_Interp * interp, int argc, tcl_const char *argv[]) { int i; if (argc >= 2) { if (strcmp (argv[1], "parameters") == 0) { vssolution.imag_part = atoi (Tcl_GetVar (interp, "::visoptions.imaginary", TCL_GLOBAL_ONLY)); vssolution.usetexture = atoi (Tcl_GetVar (interp, "::visoptions.usetexture", TCL_GLOBAL_ONLY)); if (atoi (Tcl_GetVar (interp, "::visoptions.redrawperiodic", TCL_GLOBAL_ONLY))) vssolution.usetexture = 2; vssolution.invcolor = atoi (Tcl_GetVar (interp, "::visoptions.invcolor", TCL_GLOBAL_ONLY)); vssolution.clipsolution = 0; if (strcmp (Tcl_GetVar (interp, "::visoptions.clipsolution", TCL_GLOBAL_ONLY), "scal") == 0) vssolution.clipsolution = 1; if (strcmp (Tcl_GetVar (interp, "::visoptions.clipsolution", TCL_GLOBAL_ONLY), "vec") == 0) vssolution.clipsolution = 2; tcl_const char * scalname = Tcl_GetVar (interp, "::visoptions.scalfunction", TCL_GLOBAL_ONLY); tcl_const char * vecname = Tcl_GetVar (interp, "::visoptions.vecfunction", TCL_GLOBAL_ONLY); tcl_const char * fieldlines_vecname = Tcl_GetVar (interp, "::visoptions.fieldlinesvecfunction", TCL_GLOBAL_ONLY); vssolution.scalfunction = -1; vssolution.vecfunction = -1; vssolution.fieldlines_vecfunction = -1; int pointpos; // SZ const char * pch = strchr(scalname,'.'); pointpos = int(pch-scalname+1); for (i = 0; i < vssolution.soldata.Size(); i++) { if ( (strlen (vssolution.soldata[i]->name) == pointpos-1) && (strncmp (vssolution.soldata[i]->name, scalname, pointpos-1) == 0) ) { vssolution.scalfunction = i; vssolution.scalcomp = atoi (scalname + pointpos); if ( vssolution.scalcomp > vssolution.soldata[i]->components ) vssolution.scalcomp = 1; char newscalname[100]; for ( int ii = 0; ii < pointpos; ii++ ) newscalname[ii] = scalname[ii]; newscalname[pointpos] = '.'; sprintf (newscalname+pointpos, "%i", vssolution.scalcomp); if (strcmp (scalname, newscalname) != 0) Tcl_SetVar ( interp, "::visoptions.scalfunction", newscalname, TCL_GLOBAL_ONLY ); scalname = Tcl_GetVar (interp, "::visoptions.scalfunction", TCL_GLOBAL_ONLY); } if (strcmp (vssolution.soldata[i]->name, vecname) == 0) { vssolution.vecfunction = i; //cout << "set vecfunction to " << i << endl; } if (strcmp (vssolution.soldata[i]->name, fieldlines_vecname) == 0) { vssolution.fieldlines_vecfunction = i; //cout << "set fieldlines-vecfunction to " << i << endl; } } if(vssolution.fieldlines_vecfunction != -1 && vssolution.vecfunction == -1) { //cout << "WARNING: Setting vector function in Visualization toolbox to value from Fieldlines toolbox!" << endl; vssolution.vecfunction = vssolution.fieldlines_vecfunction; } // reset visoptions.scalfunction and visoptions.vecfunction if not avialable if ( vssolution.scalfunction == -1 && strcmp (scalname, "none") != 0) Tcl_SetVar ( interp, "::visoptions.scalfunction", "none", TCL_GLOBAL_ONLY ); if ( vssolution.vecfunction == -1 && strcmp (vecname, "none") != 0) Tcl_SetVar ( interp, "::visoptions.vecfunction", "none", TCL_GLOBAL_ONLY ); tcl_const char * evalname = Tcl_GetVar (interp, "::visoptions.evaluate", TCL_GLOBAL_ONLY); if (strcmp(evalname, "abs") == 0) vssolution.evalfunc = VisualSceneSolution::FUNC_ABS; if (strcmp(evalname, "abstens") == 0) vssolution.evalfunc = VisualSceneSolution::FUNC_ABS_TENSOR; if (strcmp(evalname, "mises") == 0) vssolution.evalfunc = VisualSceneSolution::FUNC_MISES; if (strcmp(evalname, "main") == 0) vssolution.evalfunc = VisualSceneSolution::FUNC_MAIN; vssolution.gridsize = atoi (Tcl_GetVar (interp, "::visoptions.gridsize", TCL_GLOBAL_ONLY)); vssolution.xoffset = atof (Tcl_GetVar (interp, "::visoptions.xoffset", TCL_GLOBAL_ONLY)); // cout << "x-offset:" << vssolution.xoffset << endl; vssolution.yoffset = atof (Tcl_GetVar (interp, "::visoptions.yoffset", TCL_GLOBAL_ONLY)); vssolution.autoscale = atoi (Tcl_GetVar (interp, "::visoptions.autoscale", TCL_GLOBAL_ONLY)); /* vssolution.linear_colors = atoi (Tcl_GetVar (interp, "::visoptions.lineartexture", TCL_GLOBAL_ONLY)); */ vssolution.logscale = atoi (Tcl_GetVar (interp, "::visoptions.logscale", TCL_GLOBAL_ONLY)); vssolution.mminval = atof (Tcl_GetVar (interp, "::visoptions.mminval", TCL_GLOBAL_ONLY)); vssolution.mmaxval = atof (Tcl_GetVar (interp, "::visoptions.mmaxval", TCL_GLOBAL_ONLY)); vssolution.showclipsolution = atoi (Tcl_GetVar (interp, "::visoptions.showclipsolution", TCL_GLOBAL_ONLY)); vssolution.showsurfacesolution = atoi (Tcl_GetVar (interp, "::visoptions.showsurfacesolution", TCL_GLOBAL_ONLY)); vssolution.lineartexture = atoi (Tcl_GetVar (interp, "::visoptions.lineartexture", TCL_GLOBAL_ONLY)); vssolution.numtexturecols = atoi (Tcl_GetVar (interp, "::visoptions.numtexturecols", TCL_GLOBAL_ONLY)); vssolution.multidimcomponent = atoi (Tcl_GetVar (interp, "::visoptions.multidimcomponent", TCL_GLOBAL_ONLY)); vssolution.drawpointcurves = atoi (Tcl_GetVar (interp, "::visoptions.drawpointcurves", TCL_GLOBAL_ONLY)); vssolution.draw_fieldlines = atoi (Tcl_GetVar (interp, "::visoptions.drawfieldlines", TCL_GLOBAL_ONLY)); vssolution.num_fieldlines = atoi (Tcl_GetVar (interp, "::visoptions.numfieldlines", TCL_GLOBAL_ONLY)); vssolution.fieldlines_randomstart = atoi (Tcl_GetVar (interp, "::visoptions.fieldlinesrandomstart", TCL_GLOBAL_ONLY)); vssolution.fieldlines_reltolerance = atof (Tcl_GetVar (interp, "::visoptions.fieldlinestolerance", TCL_GLOBAL_ONLY)); if (strcmp (Tcl_GetVar (interp, "::visoptions.fieldlinesrktype", TCL_GLOBAL_ONLY), "euler") == 0) vssolution.fieldlines_rktype = 0; else if (strcmp (Tcl_GetVar (interp, "::visoptions.fieldlinesrktype", TCL_GLOBAL_ONLY), "eulercauchy") == 0) vssolution.fieldlines_rktype = 1; else if (strcmp (Tcl_GetVar (interp, "::visoptions.fieldlinesrktype", TCL_GLOBAL_ONLY), "simpson") == 0) vssolution.fieldlines_rktype = 2; else if (strcmp (Tcl_GetVar (interp, "::visoptions.fieldlinesrktype", TCL_GLOBAL_ONLY), "crungekutta") == 0) vssolution.fieldlines_rktype = 3; vssolution.fieldlines_rellength = atof (Tcl_GetVar (interp, "::visoptions.fieldlineslength", TCL_GLOBAL_ONLY)); vssolution.fieldlines_maxpoints = atoi (Tcl_GetVar (interp, "::visoptions.fieldlinesmaxpoints", TCL_GLOBAL_ONLY)); vssolution.fieldlines_relthickness = atof (Tcl_GetVar (interp, "::visoptions.fieldlinesthickness", TCL_GLOBAL_ONLY)); vssolution.fieldlines_fixedphase = (atoi (Tcl_GetVar (interp, "::visoptions.fieldlinesonlyonephase", TCL_GLOBAL_ONLY)) != 0); if(vssolution.fieldlines_fixedphase) vssolution.fieldlines_phase = atof (Tcl_GetVar (interp, "::visoptions.fieldlinesphase", TCL_GLOBAL_ONLY)); if (strcmp (Tcl_GetVar (interp, "::visoptions.fieldlinesstartarea", TCL_GLOBAL_ONLY), "box") == 0) vssolution.fieldlines_startarea = 0; else if (strcmp (Tcl_GetVar (interp, "::visoptions.fieldlinesstartarea", TCL_GLOBAL_ONLY), "file") == 0) vssolution.fieldlines_startarea = 1; else if (strcmp (Tcl_GetVar (interp, "::visoptions.fieldlinesstartarea", TCL_GLOBAL_ONLY), "face") == 0) vssolution.fieldlines_startarea = 2; if (vssolution.fieldlines_startarea == 0) { vssolution.fieldlines_startarea_parameter.SetSize(6); vssolution.fieldlines_startarea_parameter[0] = atof (Tcl_GetVar (interp, "::visoptions.fieldlinesstartareap1x", TCL_GLOBAL_ONLY)); vssolution.fieldlines_startarea_parameter[1] = atof (Tcl_GetVar (interp, "::visoptions.fieldlinesstartareap1y", TCL_GLOBAL_ONLY)); vssolution.fieldlines_startarea_parameter[2] = atof (Tcl_GetVar (interp, "::visoptions.fieldlinesstartareap1z", TCL_GLOBAL_ONLY)); vssolution.fieldlines_startarea_parameter[3] = atof (Tcl_GetVar (interp, "::visoptions.fieldlinesstartareap2x", TCL_GLOBAL_ONLY)); vssolution.fieldlines_startarea_parameter[4] = atof (Tcl_GetVar (interp, "::visoptions.fieldlinesstartareap2y", TCL_GLOBAL_ONLY)); vssolution.fieldlines_startarea_parameter[5] = atof (Tcl_GetVar (interp, "::visoptions.fieldlinesstartareap2z", TCL_GLOBAL_ONLY)); } else if (vssolution.fieldlines_startarea == 1) { vssolution.fieldlines_filename = Tcl_GetVar (interp, "::visoptions.fieldlinesfilename", TCL_GLOBAL_ONLY); } else if (vssolution.fieldlines_startarea == 2) { vssolution.fieldlines_startface = atoi (Tcl_GetVar (interp, "::visoptions.fieldlinesstartface", TCL_GLOBAL_ONLY)); } vssolution.deform = atoi (Tcl_GetVar (interp, "::visoptions.deformation", TCL_GLOBAL_ONLY)); vssolution.scaledeform = atof (Tcl_GetVar (interp, "::visoptions.scaledeform1", TCL_GLOBAL_ONLY)) * atof (Tcl_GetVar (interp, "::visoptions.scaledeform2", TCL_GLOBAL_ONLY)); if (atoi (Tcl_GetVar (interp, "::visoptions.isolines", TCL_GLOBAL_ONLY))) vssolution.numisolines = atoi (Tcl_GetVar (interp, "::visoptions.numiso", TCL_GLOBAL_ONLY)); else vssolution.numisolines = 0; vssolution.draw_isosurface = atoi (Tcl_GetVar (interp, "::visoptions.isosurf", TCL_GLOBAL_ONLY)); vssolution.SetSubdivision(atoi (Tcl_GetVar (interp, "::visoptions.subdivisions", TCL_GLOBAL_ONLY))); vssolution.UpdateSolutionTimeStamp(); } if (strcmp (argv[1], "parametersrange") == 0) { vssolution.invcolor = atoi (Tcl_GetVar (interp, "::visoptions.invcolor", TCL_GLOBAL_ONLY)); vssolution.mminval = atof (Tcl_GetVar (interp, "::visoptions.mminval", TCL_GLOBAL_ONLY)); vssolution.mmaxval = atof (Tcl_GetVar (interp, "::visoptions.mmaxval", TCL_GLOBAL_ONLY)); vssolution.lineartexture = atoi (Tcl_GetVar (interp, "::visoptions.lineartexture", TCL_GLOBAL_ONLY)); vssolution.numtexturecols = atoi (Tcl_GetVar (interp, "::visoptions.numtexturecols", TCL_GLOBAL_ONLY)); if (vssolution.usetexture == 0 || vssolution.logscale) vssolution.UpdateSolutionTimeStamp(); } if (argc >= 3 && strcmp (argv[1], "time") == 0) { vssolution.time = double (atoi (argv[2])) / 1000; vssolution.timetimestamp = NextTimeStamp(); cout << "\rtime = " << vssolution.time << " " << flush; } } #ifdef PARALLELGL vsmesh.Broadcast (); #endif return TCL_OK; } int Ng_Vis_Field (ClientData clientData, Tcl_Interp * interp, int argc, tcl_const char *argv[]) { int i; static char buf[1000]; buf[0] = 0; if (argc >= 2) { if (strcmp (argv[1], "setfield") == 0) { if (argc < 3) return TCL_ERROR; for (i = 0; i < vssolution.GetNSolData(); i++) if (strcmp (vssolution.GetSolData(i)->name, argv[2]) == 0) { cout << "found soldata " << i << endl; } } if (strcmp (argv[1], "getnfieldnames") == 0) { sprintf (buf, "%d", vssolution.GetNSolData()); } if (strcmp (argv[1], "getfieldname") == 0) { sprintf (buf, "%s", vssolution.GetSolData(atoi(argv[2])-1)->name); } if (strcmp (argv[1], "iscomplex") == 0) { sprintf (buf, "%d", vssolution.GetSolData(atoi(argv[2])-1)->iscomplex); } if (strcmp (argv[1], "getfieldcomponents") == 0) { sprintf (buf, "%d", vssolution.GetSolData(atoi(argv[2])-1)->components); } if (strcmp (argv[1], "getfieldnames") == 0) { for (i = 0; i < vssolution.GetNSolData(); i++) { strcat (buf, vssolution.GetSolData(i)->name); strcat (buf, " "); } strcat (buf, "var1 var2 var3"); Tcl_SetResult (interp, buf, TCL_STATIC); } if (strcmp (argv[1], "setcomponent") == 0) { cout << "set component " << argv[2] << endl; } if (strcmp (argv[1], "getactivefield") == 0) { sprintf (buf, "1"); } if (strcmp (argv[1], "getdimension") == 0) { sprintf (buf, "%d", mesh->GetDimension()); } } Tcl_SetResult (interp, buf, TCL_STATIC); return TCL_OK; } extern "C" int Ng_Vis_Init (Tcl_Interp * interp); int Ng_Vis_Init (Tcl_Interp * interp) { Tcl_CreateCommand (interp, "Ng_Vis_Set", Ng_Vis_Set, (ClientData)NULL, (Tcl_CmdDeleteProc*) NULL); Tcl_CreateCommand (interp, "Ng_Vis_Field", Ng_Vis_Field, (ClientData)NULL, (Tcl_CmdDeleteProc*) NULL); return TCL_OK; } } #endif // NOTCL netgen-4.9.13/libsrc/visualization/vscsg.cpp0000644000175000001440000001203711240003502016003 00000000000000#ifndef NOTCL #include #include "incvis.hpp" #include #include #include #include #include namespace netgen { /* *********************** Draw Geometry **************** */ extern Array > project1, project2; extern AutoPtr geometry; VisualSceneGeometry :: VisualSceneGeometry () : VisualScene() { selsurf = 0; } VisualSceneGeometry :: ~VisualSceneGeometry () { ; } void VisualSceneGeometry :: SelectSurface (int aselsurf) { selsurf = aselsurf; DrawScene(); } void VisualSceneGeometry :: DrawScene () { int i; if (changeval != geometry->GetChangeVal()) BuildScene(); changeval = geometry->GetChangeVal(); glClearColor(backcolor, backcolor, backcolor, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); SetLight(); glPushMatrix(); glMultMatrixf (transformationmat); SetClippingPlane (); glShadeModel (GL_SMOOTH); glDisable (GL_COLOR_MATERIAL); glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* float mat_spec_col[] = { 1, 1, 1, 1 }; glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, mat_spec_col); */ double shine = vispar.shininess; double transp = vispar.transp; glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, shine); glLogicOp (GL_COPY); glEnable (GL_NORMALIZE); for (i = 0; i < geometry->GetNTopLevelObjects(); i++) { const TopLevelObject * tlo = geometry -> GetTopLevelObject (i); if (tlo->GetVisible() && !tlo->GetTransparent()) { float mat_col[] = { tlo->GetRed(), tlo->GetGreen(), tlo->GetBlue(), 1 }; glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col); glCallList (trilists[i]); } } glPolygonOffset (1, 1); glEnable (GL_POLYGON_OFFSET_FILL); glLogicOp (GL_NOOP); for (i = 0; i < geometry->GetNTopLevelObjects(); i++) { const TopLevelObject * tlo = geometry -> GetTopLevelObject (i); if (tlo->GetVisible() && tlo->GetTransparent()) { float mat_col[] = { tlo->GetRed(), tlo->GetGreen(), tlo->GetBlue(), transp }; glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col); glCallList (trilists[i]); } } glDisable (GL_POLYGON_OFFSET_FILL); /* cout << "draw " << project1.Size() << " lines " << endl; glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); glLineWidth (1.0f); glEnable (GL_COLOR_MATERIAL); glColor3f (1.0f, 0.0f, 0.0f); glBegin (GL_LINES); for (int i = 0; i < project1.Size(); i++) { glVertex3dv (project1[i]); glVertex3dv (project2[i]); } glEnd(); */ glPopMatrix(); glDisable(GL_CLIP_PLANE0); /* glFlush(); int err; do { err = glGetError(); // cout << "glerr,1 = " << err << endl; } while (err != GL_NO_ERROR); // CreateTexture (0, 1, GL_DECAL); CreateTexture (0, 1, GL_MODULATE); glEnable (GL_TEXTURE_1D); float mat_col[] = { 1.0, 1.0, 1.0 }; glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col); glDisable (GL_BLEND); glDisable (GL_COLOR_MATERIAL); glEnable (GL_NORMALIZE); if (geometry->GetNTopLevelObjects()) { cout << "call list" << endl; glCallList (trilists[0]); } glColor3d (1.0, 1.0, 1.0); glBegin (GL_TRIANGLES); glNormal3f (0, 0, 1); SetOpenGlColor (-1.0, 0, 1, 0); glVertex3f (0.0, 0.0, 0.0); SetOpenGlColor (0.5, 0, 1, 0); glNormal3f (0, 0, 1); glVertex3f (1.0, 0.0, 0.0); SetOpenGlColor (2.0, 0, 1, 0); glNormal3f (0, 0, 1); glVertex3f (0.0, 1.0, 0.0); glEnd (); cout << "trig drawn" << endl; glDisable (GL_TEXTURE_1D); glDisable (GL_COLOR_MATERIAL); glFlush(); cout << "glerr,2 = " << glGetError() << endl; */ DrawCoordinateCross (); DrawNetgenLogo (); glFinish(); } void VisualSceneGeometry :: BuildScene (int zoomall) { Box<3> box; int hasp = 0; for (int i = 0; i < geometry->GetNTopLevelObjects(); i++) { const TriangleApproximation & ta = *geometry->GetTriApprox(i); if (!&ta) continue; for (int j = 0; j < ta.GetNP(); j++) { if (hasp) box.Add (ta.GetPoint(j)); else { hasp = 1; box.Set (ta.GetPoint(j)); } } } if (hasp) { center = box.Center(); rad = box.Diam() / 2; } else { center = Point3d(0,0,0); rad = 1; } CalcTransformationMatrices(); for (int i = 0; i < trilists.Size(); i++) glDeleteLists (trilists[i], 1); trilists.SetSize(0); for (int i = 0; i < geometry->GetNTopLevelObjects(); i++) { trilists.Append (glGenLists (1)); glNewList (trilists.Last(), GL_COMPILE); glEnable (GL_NORMALIZE); const TriangleApproximation & ta = *geometry->GetTriApprox(i); if (&ta) { glBegin (GL_TRIANGLES); for (int j = 0; j < ta.GetNT(); j++) { for (int k = 0; k < 3; k++) { int pi = ta.GetTriangle(j)[k]; glNormal3dv (ta.GetNormal (pi)); glVertex3dv (ta.GetPoint(pi)); } } glEnd (); } glEndList (); } } } #endif // NOTCL netgen-4.9.13/libsrc/visualization/meshdoc.cpp0000644000175000001440000003125011240003502016276 00000000000000#ifndef NOTCL #include #include // #include "incvis.hpp" #include namespace netgen { // #include "meshdoc.hpp" MeshDoctorParameters meshdoctor; VisualSceneMeshDoctor vsmeshdoc; extern AutoPtr mesh; int Ng_MeshDoctor (ClientData clientData, Tcl_Interp * interp, int argc, tcl_const char *argv[]) { cout << "Mesh Doctor:" << endl; int i; for (i = 0; i < argc; i++) cout << argv[i] << " "; cout << endl; meshdoctor.active = atoi (Tcl_GetVar (interp, "::meshdoctor.active", 0)); if (argc >= 2) { if (strcmp (argv[1], "markedgedist") == 0) { vsmeshdoc.SetMarkEdgeDist (atoi (argv[2])); } if (strcmp (argv[1], "deletemarkedsegments") == 0) { for (i = 1; i <= mesh->GetNSeg(); i++) if (vsmeshdoc.IsSegmentMarked (i)) mesh->DeleteSegment (i); // for (i = 1; i <= mesh->GetNSE(); i++) // mesh->SurfaceElement(i).SetIndex (1); mesh->Compress(); } } vsmeshdoc.UpdateTables (); vsmeshdoc.BuildScene(); return TCL_OK; } VisualSceneMeshDoctor :: VisualSceneMeshDoctor () : VisualScene() { filledlist = 0; outlinelist = 0; edgelist = 0; selelement = 0; locpi = 1; selpoint = 0; selpoint2 = 0; markedgedist = 1; UpdateTables (); } VisualSceneMeshDoctor :: ~VisualSceneMeshDoctor () { ; } void VisualSceneMeshDoctor :: DrawScene () { if (!mesh) return; int hchval = mesh->GetNP() + mesh->GetNE() + mesh->GetNSE(); if (changeval != hchval) { changeval = hchval; BuildScene(); } glClearColor(backcolor, backcolor, backcolor, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable (GL_COLOR_MATERIAL); glColor3f (1.0f, 1.0f, 1.0f); glLineWidth (1.0f); SetLight(); glPushMatrix(); glMultMatrixf (transformationmat); glInitNames (); glPushName (0); glPolygonOffset (1, 1); glEnable (GL_POLYGON_OFFSET_FILL); SetClippingPlane (); if (vispar.drawfilledtrigs) glCallList (filledlist); glDisable (GL_POLYGON_OFFSET_FILL); if (vispar.drawoutline) glCallList (outlinelist); glPolygonOffset (-1, -1); glEnable (GL_POLYGON_OFFSET_LINE); if (vispar.drawedges) glCallList (edgelist); glDisable (GL_POLYGON_OFFSET_LINE); glPopName(); if (selpoint > 0 && selpoint <= mesh->GetNP()) { GLfloat matcolblue[] = { 0, 0, 1, 1 }; glPointSize (10); glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, matcolblue); glBegin (GL_POINTS); const Point3d p = mesh->Point(selpoint); glVertex3f (p.X(), p.Y(), p.Z()); glEnd(); } glDisable(GL_CLIP_PLANE0); glPopMatrix(); glFinish(); } void VisualSceneMeshDoctor :: BuildScene (int zoomall) { int i, j; if (zoomall) { Point3d pmin, pmax; mesh->GetBox (pmin, pmax, -1); if (vispar.centerpoint) center = mesh->Point (vispar.centerpoint); else center = Center (pmin, pmax); rad = 0.5 * Dist (pmin, pmax); glEnable (GL_NORMALIZE); CalcTransformationMatrices(); } if (filledlist) { glDeleteLists (filledlist, 1); glDeleteLists (outlinelist, 1); glDeleteLists (edgelist, 1); } filledlist = glGenLists (1); glNewList (filledlist, GL_COMPILE); glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); glLineWidth (1.0f); glDisable (GL_COLOR_MATERIAL); for (i = 1; i <= mesh->GetNSE(); i++) { glLoadName (i); // copy to be thread-safe Element2d el = mesh->SurfaceElement (i); int drawel = 1; for (j = 1; j <= el.GetNP(); j++) { if (!el.PNum(j)) drawel = 0; } if (!drawel) continue; GLfloat matcol[] = { 0, 1, 0, 1 }; GLfloat matcolsel[] = { 1, 0, 0, 1 }; if (i == selelement) glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, matcolsel); else glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, matcol); if (el.GetNP() == 3) { glBegin (GL_TRIANGLES); const Point3d & lp1 = mesh->Point (el.PNum(1)); const Point3d & lp2 = mesh->Point (el.PNum(2)); const Point3d & lp3 = mesh->Point (el.PNum(3)); Vec3d n = Cross (Vec3d (lp1, lp2), Vec3d (lp1, lp3)); n /= (n.Length()+1e-12); glNormal3d (n.X(), n.Y(), n.Z()); if (!vispar.colormeshsize) { glVertex3d (lp1.X(), lp1.Y(), lp1.Z()); glVertex3d (lp2.X(), lp2.Y(), lp2.Z()); glVertex3d (lp3.X(), lp3.Y(), lp3.Z()); } else { double h1 = mesh->GetH (lp1); double h2 = mesh->GetH (lp2); double h3 = mesh->GetH (lp3); SetOpenGlColor (h1, 0.1, 10); glVertex3d (lp1.X(), lp1.Y(), lp1.Z()); SetOpenGlColor (h2, 0.1, 10); glVertex3d (lp2.X(), lp2.Y(), lp2.Z()); SetOpenGlColor (h3, 0.1, 10); glVertex3d (lp3.X(), lp3.Y(), lp3.Z()); } glEnd(); } else if (el.GetNP() == 4) { glBegin (GL_QUADS); const Point3d & lp1 = mesh->Point (el.PNum(1)); const Point3d & lp2 = mesh->Point (el.PNum(2)); const Point3d & lp3 = mesh->Point (el.PNum(4)); const Point3d & lp4 = mesh->Point (el.PNum(3)); Vec3d n = Cross (Vec3d (lp1, lp2), Vec3d (lp1, Center (lp3, lp4))); n /= (n.Length()+1e-12); glNormal3d (n.X(), n.Y(), n.Z()); glVertex3d (lp1.X(), lp1.Y(), lp1.Z()); glVertex3d (lp2.X(), lp2.Y(), lp2.Z()); glVertex3d (lp4.X(), lp4.Y(), lp4.Z()); glVertex3d (lp3.X(), lp3.Y(), lp3.Z()); glEnd(); } else if (el.GetNP() == 6) { glBegin (GL_TRIANGLES); static int trigs[4][3] = { { 1, 6, 5 }, { 2, 4, 6 }, { 3, 5, 4 }, { 4, 5, 6 } }; for (j = 0; j < 4; j++) { const Point3d & lp1 = mesh->Point (el.PNum(trigs[j][0])); const Point3d & lp2 = mesh->Point (el.PNum(trigs[j][1])); const Point3d & lp3 = mesh->Point (el.PNum(trigs[j][2])); Vec3d n = Cross (Vec3d (lp1, lp2), Vec3d (lp1, lp3)); n /= (n.Length() + 1e-12); glNormal3d (n.X(), n.Y(), n.Z()); glVertex3d (lp1.X(), lp1.Y(), lp1.Z()); glVertex3d (lp2.X(), lp2.Y(), lp2.Z()); glVertex3d (lp3.X(), lp3.Y(), lp3.Z()); } glEnd(); } } glLoadName (0); glEndList (); outlinelist = glGenLists (1); glNewList (outlinelist, GL_COMPILE); glLineWidth (1.0f); glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); glColor3f (0.0f, 0.0f, 0.0f); glEnable (GL_COLOR_MATERIAL); for (i = 1; i <= mesh->GetNSE(); i++) { Element2d el = mesh->SurfaceElement(i); int drawel = 1; for (j = 1; j <= el.GetNP(); j++) { if (!el.PNum(j)) drawel = 0; } if (!drawel) continue; if (el.GetNP() == 3) { glBegin (GL_TRIANGLES); const Point3d & lp1 = mesh->Point (el.PNum(1)); const Point3d & lp2 = mesh->Point (el.PNum(2)); const Point3d & lp3 = mesh->Point (el.PNum(3)); Vec3d n = Cross (Vec3d (lp1, lp2), Vec3d (lp1, lp3)); n /= (n.Length() + 1e-12); glNormal3d (n.X(), n.Y(), n.Z()); glVertex3d (lp1.X(), lp1.Y(), lp1.Z()); glVertex3d (lp2.X(), lp2.Y(), lp2.Z()); glVertex3d (lp3.X(), lp3.Y(), lp3.Z()); glEnd(); } else if (el.GetNP() == 4) { glBegin (GL_QUADS); const Point3d & lp1 = mesh->Point (el.PNum(1)); const Point3d & lp2 = mesh->Point (el.PNum(2)); const Point3d & lp3 = mesh->Point (el.PNum(4)); const Point3d & lp4 = mesh->Point (el.PNum(3)); Vec3d n = Cross (Vec3d (lp1, lp2), Vec3d (lp1, Center (lp3, lp4))); n /= (n.Length() + 1e-12); glNormal3d (n.X(), n.Y(), n.Z()); glVertex3d (lp1.X(), lp1.Y(), lp1.Z()); glVertex3d (lp2.X(), lp2.Y(), lp2.Z()); glVertex3d (lp4.X(), lp4.Y(), lp4.Z()); glVertex3d (lp3.X(), lp3.Y(), lp3.Z()); glEnd(); } else if (el.GetNP() == 6) { glBegin (GL_LINES); const Point3d & lp1 = mesh->Point (el.PNum(1)); const Point3d & lp2 = mesh->Point (el.PNum(2)); const Point3d & lp3 = mesh->Point (el.PNum(3)); const Point3d & lp4 = mesh->Point (el.PNum(4)); const Point3d & lp5 = mesh->Point (el.PNum(5)); const Point3d & lp6 = mesh->Point (el.PNum(6)); Vec3d n = Cross (Vec3d (lp1, lp2), Vec3d (lp1, lp3)); n /= (n.Length()+1e-12); glNormal3d (n.X(), n.Y(), n.Z()); glVertex3d (lp1.X(), lp1.Y(), lp1.Z()); glVertex3d (lp6.X(), lp6.Y(), lp6.Z()); glVertex3d (lp2.X(), lp2.Y(), lp2.Z()); glVertex3d (lp6.X(), lp6.Y(), lp6.Z()); glVertex3d (lp1.X(), lp1.Y(), lp1.Z()); glVertex3d (lp5.X(), lp5.Y(), lp5.Z()); glVertex3d (lp3.X(), lp3.Y(), lp3.Z()); glVertex3d (lp5.X(), lp5.Y(), lp5.Z()); glVertex3d (lp2.X(), lp2.Y(), lp2.Z()); glVertex3d (lp4.X(), lp4.Y(), lp4.Z()); glVertex3d (lp3.X(), lp3.Y(), lp3.Z()); glVertex3d (lp4.X(), lp4.Y(), lp4.Z()); glEnd(); } } glLoadName (0); glEndList (); edgelist = glGenLists (1); glNewList (edgelist, GL_COMPILE); glDisable (GL_COLOR_MATERIAL); GLfloat matcoledge[] = { 0, 0, 1, 1 }; GLfloat matcolseledge[] = { 1, 0, 1, 1 }; glLineWidth (2.0f); for (i = 1; i <= mesh->GetNSeg(); i++) { const Segment & seg = mesh->LineSegment(i); const Point3d & p1 = mesh->Point(seg[0]); const Point3d & p2 = mesh->Point(seg[1]); if (edgedist.Get(seg[0]) <= markedgedist && edgedist.Get(seg[1]) <= markedgedist) { glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, matcolseledge); glLineWidth (4.0f); } else { glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, matcoledge); glLineWidth (2.0f); } glBegin (GL_LINES); glVertex3f (p1.X(), p1.Y(), p1.Z()); glVertex3f (p2.X(), p2.Y(), p2.Z()); glEnd(); } glLineWidth (1.0f); glEndList (); } void VisualSceneMeshDoctor :: MouseDblClick (int px, int py) { cout << "dblclick: " << px << " - " << py << endl; int i, hits; // select surface triangle by mouse click GLuint selbuf[10000]; glSelectBuffer (10000, selbuf); glRenderMode (GL_SELECT); GLint viewport[4]; glGetIntegerv (GL_VIEWPORT, viewport); glMatrixMode (GL_PROJECTION); glPushMatrix(); GLdouble projmat[16]; glGetDoublev (GL_PROJECTION_MATRIX, projmat); glLoadIdentity(); gluPickMatrix (px, viewport[3] - py, 1, 1, viewport); glMultMatrixd (projmat); glClearColor(backcolor, backcolor, backcolor, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode (GL_MODELVIEW); glPushMatrix(); glMultMatrixf (transformationmat); glInitNames(); glPushName (1); glPolygonOffset (1, 1); glEnable (GL_POLYGON_OFFSET_FILL); glCallList (filledlist); glDisable (GL_POLYGON_OFFSET_FILL); glPopName(); glMatrixMode (GL_PROJECTION); glPopMatrix(); glMatrixMode (GL_MODELVIEW); glPopMatrix(); glFlush(); hits = glRenderMode (GL_RENDER); cout << "hits = " << hits << endl; int minname = 0; GLuint mindepth = 0; for (i = 0; i < hits; i++) { int curname = selbuf[4*i+3]; GLuint curdepth = selbuf[4*i+1]; if (curname && (curdepth < mindepth || !minname)) { mindepth = curdepth; minname = curname; } } cout << "clicked element: " << minname << endl; ClickElement (minname); BuildScene (); } void VisualSceneMeshDoctor :: SetMarkEdgeDist (int dist) { markedgedist = dist; BuildScene(); } void VisualSceneMeshDoctor :: ClickElement (int elnr) { selelement = elnr; int oldlocpi = locpi; locpi = locpi % 3 + 1; if (selelement > 0 && selelement <= mesh->GetNSE()) { selpoint = mesh->SurfaceElement(selelement).PNum(locpi); selpoint2 = mesh->SurfaceElement(selelement).PNum(oldlocpi); cout << "selpts = " << selpoint << ", " << selpoint2 << endl; } UpdateTables(); } void VisualSceneMeshDoctor :: UpdateTables () { if (!mesh) return; edgedist.SetSize(mesh->GetNP()); int i, changed; for (i = 1; i <= mesh->GetNP(); i++) edgedist.Elem(i) = 10000; for (i = 1; i <= mesh->GetNSeg(); i++) { const Segment & seg = mesh->LineSegment(i); if ( (seg[0] == selpoint && seg[1] == selpoint2) || (seg[1] == selpoint && seg[0] == selpoint2) ) { edgedist.Elem(selpoint) = 1; edgedist.Elem(selpoint2) = 1; } } do { changed = 0; for (i = 1; i <= mesh->GetNSeg(); i++) { const Segment & seg = mesh->LineSegment(i); int edist = min2 (edgedist.Get(seg[0]), edgedist.Get(seg[1])); edist++; if (edgedist.Get(seg[0]) > edist) { edgedist.Elem(seg[0]) = edist; changed = 1; } if (edgedist.Get(seg[1]) > edist) { edgedist.Elem(seg[1]) = edist; changed = 1; } } } while (changed); } int VisualSceneMeshDoctor :: IsSegmentMarked (int segnr) const { const Segment & seg = mesh->LineSegment(segnr); return (edgedist.Get(seg[0]) <= markedgedist && edgedist.Get(seg[1]) <= markedgedist); } } #endif // NOTCL netgen-4.9.13/libsrc/visualization/importsolution.cpp0000644000175000001440000000571611240003502017773 00000000000000// // Read solution file // #include #include #include #include #include #include namespace netgen { void ImportSolution (const char * filename) { ifstream inf (filename); char buf[100], name[1000]; int i, size, comps, order; bool iscomplex; const char * type; Flags flags; while (1) { buf[0] = 0; inf >> buf; if (strcmp (buf, "solution") == 0) { inf >> name; inf >> buf[0]; flags.DeleteFlags (); while (buf[0] == '-') { inf >> buf[1]; inf.putback (buf[1]); if (!isalpha (buf[1])) { break; } inf >> (buf+1); flags.SetCommandLineFlag (buf); buf[0] = 0; inf >> buf[0]; } inf.putback (buf[0]); (*testout) << "Flags: " << endl; flags.PrintFlags (*testout); (*testout) << "done" << endl; size = int(flags.GetNumFlag ("size", Ng_GetNP())); comps = int(flags.GetNumFlag ("components", 1)); type = flags.GetStringFlag ("type", "nodal"); order = int(flags.GetNumFlag ("order", 1)); iscomplex = flags.GetDefineFlag ("complex"); double * sol = new double[size*comps]; (*testout) << "import solution " << name << " size = " << size << " comps = " << comps << " order = " << order << endl; for (i = 0; i < size*comps; i++) { inf >> sol[i]; // (*testout) << "sol: " << sol[i] << endl; } Ng_SolutionData soldata; Ng_InitSolutionData (&soldata); soldata.name = name; soldata.data = sol; soldata.dist = comps; soldata.components = comps; soldata.order = order; soldata.iscomplex = iscomplex; soldata.soltype = NG_SOLUTION_NODAL; soldata.draw_surface = 1; soldata.draw_volume = 1; if (strcmp (type, "element") == 0) { soldata.soltype = NG_SOLUTION_ELEMENT; soldata.draw_surface = 0; } if (strcmp (type, "surfaceelement") == 0) { soldata.soltype = NG_SOLUTION_SURFACE_ELEMENT; soldata.draw_volume = 0; } if (strcmp (type, "noncontinuous") == 0) soldata.soltype = NG_SOLUTION_NONCONTINUOUS; if (strcmp (type, "surfacenoncontinuous") == 0) soldata.soltype = NG_SOLUTION_SURFACE_NONCONTINUOUS; Ng_SetSolutionData (&soldata); } else { // cout << "kw = (" << buf << ")" << endl; (*testout) << "kw = (" << buf << ")" << endl; break; } } /* struct Ng_SolutionData { char * name; // name of gridfunction double * data; // solution values int components; // used components in solution vector int dist; // num of doubles per entry (alignment!) Ng_SolutionType soltype; // type of solution function }; // initialize solution data with default arguments void Ng_InitSolutionData (Ng_SolutionData * soldata); // set solution data void Ng_SetSolutionData (Ng_SolutionData * soldata); */ } } netgen-4.9.13/libsrc/visualization/mvdraw.hpp0000644000175000001440000001517511251250334016202 00000000000000#ifndef FILE_MVDRAW #define FILE_MVDRAW namespace netgen { extern void InitDrawMesh (); extern void DrawMesh (); extern void MouseMove(int oldx, int oldy, int newx, int newy, char mode); extern void Render (); class VisualScene { protected: static Point3d center; static double rad; static float lookatmat[16]; static float transmat[16]; static float rotmat[16]; static float centermat[16]; static float transformationmat[16]; GLdouble clipplane[4]; int changeval; static GLdouble backcolor; static int selface; static int selelement; static int selpoint; static int selpoint2; static int locpi; static int seledge; static int selecttimestamp; public: // static GLubyte * colortexture; static GLuint coltexname; static int ntexcols; // static bool linear_colors; int invcolor; public: VisualScene (); virtual ~VisualScene(); virtual void BuildScene (int zoomall = 0); virtual void DrawScene (); void CalcTransformationMatrices(); void StandardRotation (const char * dir); void ArbitraryRotation (const Array & alpha, const Array & vec); void ArbitraryRotation (const double alpha, const Vec3d & vec); void MouseMove(int oldx, int oldy, int newx, int newy, char mode); void LookAt (const Point<3> & cam, const Point<3> & obj, const Point<3> & camup); void SetClippingPlane (); virtual void MouseDblClick (int px, int py); void SetLight (); static void SetBackGroundColor (double col) { backcolor = col; } void CreateTexture (int ncols, int linear, int typ = GL_DECAL); void DrawColorBar (double minval, double maxval, int logscale = 0, bool linear = 1); void DrawCoordinateCross (); void DrawNetgenLogo (); void SetOpenGlColor(double val, double valmin, double valmax, int logscale = 0); #ifdef PARALLELGL void InitParallelGL (); void Broadcast (); #endif }; extern void MyOpenGLText (const char * text); class VisualSceneGeometry : public VisualScene { Array trilists; int selsurf; public: VisualSceneGeometry (); virtual ~VisualSceneGeometry (); virtual void SelectSurface (int aselsurf); virtual void BuildScene (int zoomall = 0); virtual void DrawScene (); }; class VisualSceneSTLGeometry : public VisualScene { Array trilists; public: VisualSceneSTLGeometry (); virtual ~VisualSceneSTLGeometry (); virtual void BuildScene (int zoomall = 0); virtual void DrawScene (); }; class VisualSceneGeometry2d : public VisualScene { public: VisualSceneGeometry2d (); virtual ~VisualSceneGeometry2d (); virtual void BuildScene (int zoomall = 0); virtual void DrawScene (); }; #ifdef OCCGEOMETRY class VisualSceneOCCGeometry : public VisualScene { Array trilists; Array linelists; int selsurf; public: VisualSceneOCCGeometry (); virtual ~VisualSceneOCCGeometry (); virtual void BuildScene (int zoomall = 0); virtual void DrawScene (); virtual void MouseDblClick (int px, int py); }; #endif #ifdef STEP class VisualSceneSTEPGeometry : public VisualScene { Array gllists; public: VisualSceneSTEPGeometry (); virtual ~VisualSceneSTEPGeometry (); virtual void BuildScene (int zoomall = 0); virtual void DrawScene (); }; #endif class VisualSceneSTLMeshing : public VisualScene { Array trilists; int selecttrig, nodeofseltrig; public: VisualSceneSTLMeshing (); virtual ~VisualSceneSTLMeshing (); virtual void BuildScene (int zoomall = 0); virtual void DrawScene (); virtual void MouseDblClick (int px, int py); int seltria; }; class VisualSceneSurfaceMeshing : public VisualScene { public: VisualSceneSurfaceMeshing (); virtual ~VisualSceneSurfaceMeshing (); virtual void BuildScene (int zoomall = 0); virtual void DrawScene (); }; class VisualSceneMesh : public VisualScene { int filledlist; int linelist; int edgelist; int pointnumberlist; int tetlist; int prismlist; int pyramidlist; int hexlist; int badellist; int identifiedlist; int domainsurflist; int vstimestamp;//, selecttimestamp; int filledtimestamp; int linetimestamp; int edgetimestamp; int pointnumbertimestamp; int tettimestamp; int prismtimestamp; int pyramidtimestamp; int hextimestamp; int badeltimestamp; int identifiedtimestamp; int domainsurftimestamp; #ifdef PARALLELGL Array par_linelists; Array par_filledlists; #endif NgLock *lock; // int selface, selelement; // int selpoint, selpoint2, locpi; // int seledge; double minh, maxh; // for meshsize coloring public: VisualSceneMesh (); virtual ~VisualSceneMesh (); virtual void BuildScene (int zoomall = 0); virtual void DrawScene (); virtual void MouseDblClick (int px, int py); int SelectedFace () const { return selface; } void SetSelectedFace (int asf); // { selface = asf; selecttimestamp = GetTimeStamp(); } int SelectedEdge () const { return seledge; } int SelectedElement () const { return selelement; } int SelectedPoint () const { return selpoint; } void BuildFilledList(); // private: void BuildLineList(); void BuildEdgeList(); void BuildPointNumberList(); void BuildTetList(); void BuildPrismList(); void BuildPyramidList(); void BuildHexList(); void BuildBadelList(); void BuildIdentifiedList(); void BuildDomainSurfList(); }; class VisualSceneSpecPoints : public VisualScene { public: VisualSceneSpecPoints (); virtual ~VisualSceneSpecPoints (); virtual void BuildScene (int zoomall = 0); virtual void DrawScene (); double len; }; // extern struct Tcl_Interp * hinterp; extern void AddVisualizationScene (const string & name, VisualScene * vs); void MouseDblClickSelect (const int px, const int py, const GLdouble * clipplane, const GLdouble backcolor, const float * transformationmat, const Point3d & center, const double rad, const int displaylist, int & selelement, int & selface, int & seledge, int & selpoint, int & selpoint2, int & locpi); } #endif netgen-4.9.13/libsrc/visualization/mvdraw.cpp0000644000175000001440000010011011343727624016172 00000000000000#include #include #include #include #include #include #include // #include #ifndef WIN32 #define GLX_GLXEXT_LEGACY #include #include #include /* for XA_RGB_DEFAULT_MAP atom */ // #include // for parallel GL ??? #endif namespace netgen { Point3d VisualScene :: center; double VisualScene :: rad; GLdouble VisualScene :: backcolor; /* #if TOGL_MAJOR_VERSION!=2 GLuint VisualScene :: fontbase = 0; #else Tcl_Obj * VisualScene :: fontbase = NULL; Togl * VisualScene :: globtogl; #endif */ // texture for color decoding // GLubyte * VisualScene :: colortexture = NULL; GLuint VisualScene :: coltexname = 1; int VisualScene :: ntexcols = -1; float VisualScene :: lookatmat[16]; float VisualScene :: transmat[16]; float VisualScene :: rotmat[16]; float VisualScene :: centermat[16]; float VisualScene :: transformationmat[16]; int VisualScene :: selface; int VisualScene :: selelement; int VisualScene :: selpoint; int VisualScene :: selpoint2; int VisualScene :: locpi; int VisualScene :: seledge; int VisualScene :: selecttimestamp; VisualizationParameters :: VisualizationParameters() { lightamb = 0.3; lightdiff = 0.7; lightspec = 1; shininess = 50; transp = 0.3; locviewer = 0; showstltrias = 0; centerpoint = 0; usedispllists = 1; strcpy (selectvisual, "cross"); use_center_coords = false; }; VisualizationParameters vispar; double dist = 0; // double dist = 6; // vorher: pnear = 2; double pnear = 0.1; double pfar = 10; extern STLGeometry * stlgeometry; extern AutoPtr geometry2d; extern AutoPtr mesh; extern Array specpoints; extern Array > boxes; VisualScene :: VisualScene () { changeval = -1; backcolor = 0; } VisualScene :: ~VisualScene() { ; } void Render () { multithread.redraw = 1; } void VisualScene :: BuildScene (int zoomall) { center = Point3d (0,0,0); rad = 1; CalcTransformationMatrices(); glEnable(GL_DEPTH_TEST); glDisable (GL_DITHER); GLfloat ambvals[] = { 0.4f, 0.4f, 0.4f, 1.0f }; GLfloat diffvals[] = { 0.5f, 0.5f, 0.5f, 1.0f }; GLfloat specvals[] = { 0.7f, 0.7f, 0.7f, 1.0f }; glLightfv(GL_LIGHT0, GL_AMBIENT, ambvals); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffvals); glLightfv(GL_LIGHT0, GL_SPECULAR, specvals); GLfloat light_position[] = { 1, 3, 3, 0 }; glLightfv(GL_LIGHT0, GL_POSITION, light_position); glLightModeli (GL_LIGHT_MODEL_TWO_SIDE, 0); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); } void VisualScene :: DrawScene () { if (changeval == -1) BuildScene(); changeval = 0; glClearColor(backcolor, backcolor, backcolor, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable (GL_COLOR_MATERIAL); glColor3f (1.0f, 1.0f, 1.0f); glLineWidth (1.0f); DrawCoordinateCross (); DrawNetgenLogo (); glFinish(); } void VisualScene :: CalcTransformationMatrices() { // prepare model view matrix glPushMatrix(); glLoadIdentity(); gluLookAt (0, 0, 6, 0, 0, 0, 0, 1, 0); glGetFloatv (GL_MODELVIEW_MATRIX, lookatmat); glLoadIdentity(); glTranslatef(0.0f, 0.0f, -dist); glGetFloatv (GL_MODELVIEW_MATRIX, transmat); glLoadIdentity(); glGetFloatv (GL_MODELVIEW_MATRIX, rotmat); glScalef (1/rad, 1/rad, 1/rad); glTranslated (-center.X(), -center.Y(), -center.Z()); glGetFloatv (GL_MODELVIEW_MATRIX, centermat); glLoadIdentity(); glMultMatrixf (lookatmat); glMultMatrixf (transmat); glMultMatrixf (rotmat); glMultMatrixf (centermat); glGetFloatv (GL_MODELVIEW_MATRIX, transformationmat); glPopMatrix(); } void VisualScene :: ArbitraryRotation (const Array & alpha, const Array & vec) { glPushMatrix(); glLoadIdentity(); for(int i=0; i a(1); a[0] = alpha; Array v(1); v[0] = vec; ArbitraryRotation(a,v); } void VisualScene :: StandardRotation (const char * dir) { glPushMatrix(); glLoadIdentity(); if (strcmp (dir, "xy") == 0) ; else if (strcmp (dir, "yx") == 0) glRotatef(180.0, 1.0f, 1.0f, 0.0f); else if (strcmp (dir, "xz") == 0) glRotatef(-90.0, 1.0f, 0.0f, 0.0f); else if (strcmp (dir, "zx") == 0) { glRotatef(180.0, 1.0f, 1.0f, 0.0f); glRotatef(-90.0, 1.0f, 0.0f, 0.0f); } else if (strcmp (dir, "yz") == 0) { glRotatef(-90.0, 0.0f, 0.0f, 1.0f); glRotatef(-90.0, 0.0f, 1.0f, 0.0f); } else if (strcmp (dir, "zy") == 0) glRotatef(90.0, 0.0f, 1.0f, 0.0f); glGetFloatv (GL_MODELVIEW_MATRIX, rotmat); glLoadIdentity(); glMultMatrixf (lookatmat); glMultMatrixf (transmat); glMultMatrixf (rotmat); glMultMatrixf (centermat); glGetFloatv (GL_MODELVIEW_MATRIX, transformationmat); glPopMatrix(); } void VisualScene :: MouseMove(int oldx, int oldy, int newx, int newy, char mode) { int deltax = newx - oldx; int deltay = newy - oldy; glPushMatrix(); glLoadIdentity (); switch (mode) { case 'r': { glRotatef(float(deltax)/2, 0.0f, 1.0f, 0.0f); glRotatef(float(deltay)/2, 1.0f, 0.0f, 0.0f); glMultMatrixf (rotmat); glGetFloatv (GL_MODELVIEW_MATRIX, rotmat); break; } case 'm': { GLdouble projmat[16], modelviewmat[16]; GLint viewport[4]; glGetDoublev (GL_PROJECTION_MATRIX, projmat); glGetDoublev (GL_MODELVIEW_MATRIX, modelviewmat); glGetIntegerv (GL_VIEWPORT, viewport); // vorher pvz1/2 = 0 GLdouble pvx1 = 0, pvy1 = 0, pvz1 = 0.99; // 0.95; GLdouble pvx2 = deltax, pvy2 = -deltay, pvz2 = 0.99; // 0.95; GLdouble px1, py1, pz1; GLdouble px2, py2, pz2; gluUnProject (pvx1, pvy1, pvz1, modelviewmat, projmat, viewport, &px1, &py1, &pz1); gluUnProject (pvx2, pvy2, pvz2, modelviewmat, projmat, viewport, &px2, &py2, &pz2); /* gluUnProject (oldx, oldy, 1, modelviewmat, projmat, viewport, &px1, &py1, &pz1); gluUnProject (newx, newy, 1, modelviewmat, projmat, viewport, &px2, &py2, &pz2); */ /* cout << "pv1 = " << pvx1 << ", " << pvy1 << ", " << pvz1 << endl; cout << "p1 = " << px1 << ", " << py1 << ", " << pz1 << endl; */ glTranslated (px2-px1, py2-py1, pz2-pz1); glMultMatrixf (transmat); glGetFloatv (GL_MODELVIEW_MATRIX, transmat); break; } case 'z': { // glTranslatef(0.0f, 0.0f, -dist); // cout << "deltay = " << deltay << endl; // cout << "float_bug = " << (float(deltay)/100) << endl; gives wrong result with icc 9.0.021 glScaled (exp (double (-deltay)/100), exp (double (-deltay)/100), exp (double (-deltay)/100)); // glTranslatef(0.0f, 0.0f, dist); glMultMatrixf (transmat); glGetFloatv (GL_MODELVIEW_MATRIX, transmat); break; } } glLoadIdentity(); glMultMatrixf (lookatmat); glMultMatrixf (transmat); glMultMatrixf (rotmat); glMultMatrixf (centermat); glGetFloatv (GL_MODELVIEW_MATRIX, transformationmat); glPopMatrix(); } void VisualScene :: LookAt (const Point<3> & cam, const Point<3> & obj, const Point<3> & camup) { glPushMatrix(); glLoadIdentity (); gluLookAt (cam(0), cam(1), cam(2), obj(0), obj(1), obj(2), camup(0), camup(1), camup(2)); glMultMatrixf (centermat); glGetFloatv (GL_MODELVIEW_MATRIX, transformationmat); glPopMatrix(); } void VisualScene :: SetClippingPlane () { if (vispar.clipenable) { Vec3d n = vispar.clipnormal; n /= (n.Length()+1e-10); clipplane[0] = n.X(); clipplane[1] = n.Y(); clipplane[2] = n.Z(); clipplane[3] = -(Vec3d(center) * n) + rad * vispar.clipdist; glClipPlane(GL_CLIP_PLANE0, clipplane); glEnable(GL_CLIP_PLANE0); } else glDisable (GL_CLIP_PLANE0); } void VisualScene :: MouseDblClick (int /* px */, int /* py */) { ; } void VisualScene :: SetLight() { GLfloat vals[3]; double lightamb = vispar.lightamb; vals[0] = vals[1] = vals[2] = lightamb; glLightfv(GL_LIGHT0, GL_AMBIENT, vals); double lightdiff = vispar.lightdiff; vals[0] = vals[1] = vals[2] = lightdiff; glLightfv(GL_LIGHT0, GL_DIFFUSE, vals); double lightspec = vispar.lightspec; vals[0] = vals[1] = vals[2] = lightspec; glLightfv(GL_LIGHT0, GL_SPECULAR, vals); glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, vispar.shininess); glLightModeli (GL_LIGHT_MODEL_LOCAL_VIEWER, vispar.locviewer); float mat_spec_col[] = { 1, 1, 1, 1 }; glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, mat_spec_col); glEnable (GL_LIGHTING); glEnable (GL_LIGHT0); } void VisualScene :: SetOpenGlColor(double val, double valmin, double valmax, int logscale) { double value; if (!logscale) value = (val - valmin) / (valmax - valmin); else { if (valmax <= 0) valmax = 1; if (valmin <= 0) valmin = 1e-4 * valmax; value = (log(fabs(val)) - log(valmin)) / (log(valmax) - log(valmin)); } if (!invcolor) value = 1 - value; glTexCoord1f ( 0.998 * value + 0.001); // glTexCoord1f ( val ); glTexCoord2f ( 0.998 * value + 0.001, 1.5); // glTexCoord1f ( value ); if (value > 1) value = 1; if (value < 0) value = 0; value *= 4; static const double colp[][3] = { { 1, 0, 0 }, { 1, 1, 0 }, { 0, 1, 0 }, { 0, 1, 1 }, { 0, 0, 1 }, // { 1, 0, 1 }, // { 1, 0, 0 }, }; int i = int(value); double r = value - i; GLdouble col[3]; for (int j = 0; j < 3; j++) col[j] = (1-r) * colp[i][j] + r * colp[i+1][j]; glColor3d (col[0], col[1], col[2]); } /* void VisualScene :: CreateTexture (int ncols, int linear, int typ) { static const double colp[][3] = { { 1, 0, 0 }, { 1, 1, 0 }, { 0, 1, 0 }, { 0, 1, 1 }, { 0, 0, 1 }, }; if (ntexcols != 1024) { ntexcols = 1024; // glPixelStorei (GL_UNPACK_ALIGNMENT, 1); glGenTextures (1, &coltexname); glBindTexture (GL_TEXTURE_1D, coltexname); glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); for (int level = 0; level <= 11; level++) { ncols = 2048 >> level; cout << "ncols = " << ncols << endl; colortexture = new GLubyte[4*ncols+12]; for (int i = 0; i < ncols; i++) { double value = 4.0 * i / (ncols-1); int iv = int(value); double r = value - iv; GLdouble col[3]; for (int j = 0; j < 3; j++) col[j] = (1-r) * colp[iv][j] + r * colp[iv+1][j]; colortexture[4*i] = GLubyte (255 * col[0]); colortexture[4*i+1] = GLubyte (255 * col[1]); colortexture[4*i+2] = GLubyte (255 * col[2]); colortexture[4*i+3] = GLubyte(255); if (ncols > 20) if ( i % (ncols / 10) == 0) { colortexture[4*i] = GLubyte (0); colortexture[4*i+1] = GLubyte (0); colortexture[4*i+2] = GLubyte (0); colortexture[4*i+4] = GLubyte (0); colortexture[4*i+5] = GLubyte (0); colortexture[4*i+6] = GLubyte (0); } } glTexImage1D (GL_TEXTURE_1D, level, 4, ncols, 0, GL_RGBA, GL_UNSIGNED_BYTE, colortexture); } } glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, typ); // DECAL or MODULATE glBindTexture (GL_TEXTURE_1D, coltexname); } */ void VisualScene :: CreateTexture (int ncols, int linear, int typ) { if (linear) ncols = 32; else ncols = 8; if (ntexcols != ncols) { ntexcols = ncols; GLubyte colortexture[4*32]; const double colp[][3] = { { 1, 0, 0 }, { 1, 1, 0 }, { 0, 1, 0 }, { 0, 1, 1 }, { 0, 0, 1 }, }; for (int i = 0; i < ncols; i++) { double value = 4.0 * i / (ncols-1); int iv = int(value); double r = value - iv; GLdouble col[3]; if(r > 1e-3) for (int j = 0; j < 3; j++) col[j] = (1.-r) * colp[iv][j] + r * colp[iv+1][j]; else for (int j = 0; j < 3; j++) col[j] = colp[iv][j]; colortexture[4*i] = GLubyte (255 * col[0]); colortexture[4*i+1] = GLubyte (255 * col[1]); colortexture[4*i+2] = GLubyte (255 * col[2]); colortexture[4*i+3] = GLubyte(255); } // glPixelStorei (GL_UNPACK_ALIGNMENT, 1); glTexImage1D (GL_TEXTURE_1D, 0, 4, ncols, 0, GL_RGBA, GL_UNSIGNED_BYTE, colortexture); glTexImage2D (GL_TEXTURE_2D, 0, 4, ncols, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, colortexture); glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, typ); // DECAL or MODULATE GLfloat bcol[] = { 1, 1, 1, 1.0 }; glTexParameterfv (GL_TEXTURE_1D, GL_TEXTURE_BORDER_COLOR, bcol); glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterfv (GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, bcol); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); if (linear) { glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); } else { glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); } } } /* void VisualScene :: CreateTexture (int ncols, int linear, int typ) { if (ncols < 2) ncols = 2; if (linear) ncols = 32; else ncols = 8; if (ntexcols != ncols) { if (colortexture) { glDeleteTextures (1, &coltexname); delete colortexture; } ntexcols = ncols; colortexture = new GLubyte[4*ncols+12]; const double colp[][3] = { { 1, 0, 0 }, { 1, 1, 0 }, { 0, 1, 0 }, { 0, 1, 1 }, { 0, 0, 1 }, }; for (int i = 0; i < ncols; i++) { double value = 4.0 * i / (ncols-1); int iv = int(value); double r = value - iv; GLdouble col[3]; for (int j = 0; j < 3; j++) col[j] = (1-r) * colp[iv][j] + r * colp[iv+1][j]; colortexture[4*i+4] = GLubyte (255 * col[0]); colortexture[4*i+5] = GLubyte (255 * col[1]); colortexture[4*i+6] = GLubyte (255 * col[2]); colortexture[4*i+7] = GLubyte(255); } for (int j = 0; j < 4; j++) { colortexture[j] = colortexture[4+j]; colortexture[ncols*4+4+j] = colortexture[ncols*4+j]; } // glPixelStorei (GL_UNPACK_ALIGNMENT, 1); glGenTextures (1, &coltexname); glBindTexture (GL_TEXTURE_1D, coltexname); glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexImage1D (GL_TEXTURE_1D, 0, 4, ncols, 0, GL_RGBA, GL_UNSIGNED_BYTE, colortexture+4); int bcol[] = { 0, 0, -1, -1 }; glTexParameteriv (GL_TEXTURE_1D, GL_TEXTURE_BORDER_COLOR, bcol); } glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, typ); // DECAL or MODULATE glBindTexture (GL_TEXTURE_1D, coltexname); if (linear) { glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); } else { glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); } } */ void VisualScene :: DrawColorBar (double minval, double maxval, int logscale, bool linear) { if (!vispar.drawcolorbar) return; CreateTexture (8, linear, GL_DECAL); if (logscale && maxval <= 0) maxval = 1; if (logscale && minval <= 0) minval = 1e-4 * maxval; double minx = -1; double maxx = 1; double miny = 0.75; double maxy = 0.8; glDisable (GL_LIGHTING); glEnable (GL_COLOR_MATERIAL); glEnable (GL_TEXTURE_1D); glNormal3d (0, 0, 1); glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); glDisable (GL_DEPTH_TEST); glBegin (GL_QUAD_STRIP); for (double x = minx; x <= maxx; x += (maxx - minx) / 50) { SetOpenGlColor (x, minx, maxx); glVertex3d (x, miny, -5); glVertex3d (x, maxy, -5); } glEnd(); glDisable (GL_TEXTURE_1D); glEnable (GL_COLOR_MATERIAL); GLfloat textcol[3] = { 1 - backcolor, 1 - backcolor, 1 - backcolor }; glColor3fv (textcol); glPushAttrib (GL_LIST_BIT); // glListBase (fontbase); char buf[20]; for (int i = 0; i <= 4; i++) { double x = minx + i * (maxx-minx) / 4; glRasterPos3d (x, 0.7,-5); double val; if (logscale) val = minval * pow (maxval / minval, i / 4.0); else val = minval + i * (maxval-minval) / 4; sprintf (buf, "%8.3e", val); // glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf); MyOpenGLText (buf); } glPopAttrib (); glEnable (GL_DEPTH_TEST); } void VisualScene :: DrawCoordinateCross () { if (!vispar.drawcoordinatecross) return; glDisable (GL_DEPTH_TEST); glMatrixMode (GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glMatrixMode (GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); GLint viewport[4]; glGetIntegerv (GL_VIEWPORT, viewport); glTranslatef (-1, -1, 0.0); glScalef (40.0 / viewport[2], 40.0 / viewport[3], 1); glTranslatef (2.0, 2.0, 0.0); glMultMatrixf (rotmat); glEnable (GL_COLOR_MATERIAL); glDisable (GL_LIGHTING); glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); GLfloat textcol[3] = { 1 - backcolor, 1 - backcolor, 1 - backcolor }; glColor3fv (textcol); glLineWidth (1.0f); double len = 1; glBegin(GL_LINES); glVertex3d (0, 0, 0); glVertex3d (len, 0, 0); glVertex3d (0.0f, 0.0f, 0.0f); glVertex3d (0.0f, len, 0.0f); glVertex3d (0.0f, 0.0f, 0.0f); glVertex3d (0.0f, 0.0f, len); glEnd (); glPushAttrib (GL_LIST_BIT); // glListBase (fontbase); char buf[20]; glRasterPos3d (len, 0.0f, 0.0f); sprintf (buf, "x"); // glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf); MyOpenGLText (buf); glRasterPos3d (0.0f, len, 0.0f); sprintf (buf, "y"); // glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf); MyOpenGLText (buf); glRasterPos3d (0.0f, 0.0f, len); sprintf (buf, "z"); // glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf); MyOpenGLText (buf); glPopAttrib (); glEnable (GL_LIGHTING); glMatrixMode (GL_PROJECTION); glPopMatrix(); glMatrixMode (GL_MODELVIEW); glPopMatrix(); glEnable (GL_DEPTH_TEST); } void VisualScene :: DrawNetgenLogo () { if (!vispar.drawnetgenlogo) return; glDisable (GL_DEPTH_TEST); glMatrixMode (GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glMatrixMode (GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); GLint viewport[4]; glGetIntegerv (GL_VIEWPORT, viewport); glTranslatef (1, -1, 0.0); glScalef (40.0 / viewport[2], 40.0 / viewport[3], 1); glTranslatef (-7.0, 2.0, 0.0); glDisable (GL_CLIP_PLANE0); glDisable (GL_LIGHTING); glEnable (GL_COLOR_MATERIAL); GLfloat textcol[3] = { 1 - backcolor, 1 - backcolor, 1 - backcolor }; glColor3fv (textcol); glLineWidth (1.0f); glPushAttrib (GL_LIST_BIT); // glListBase (fontbase); char buf[] = "Netgen " PACKAGE_VERSION; glRasterPos3d (0.0f, 0.0f, 0.0f); // glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf); MyOpenGLText (buf); glPopAttrib (); glEnable (GL_LIGHTING); glMatrixMode (GL_PROJECTION); glPopMatrix(); glMatrixMode (GL_MODELVIEW); glPopMatrix(); glEnable (GL_DEPTH_TEST); } #ifdef PARALLELGL void VisualScene :: InitParallelGL () { static int init = 0; if (!init) { init = 1; if (id == 0) { string displname; Display * dpy = glXGetCurrentDisplay(); GLXDrawable drawable = glXGetCurrentDrawable(); GLXContext ctx = glXGetCurrentContext(); GLXContextID xid = glXGetContextIDEXT (ctx); displname = XDisplayName (0); cout << "Init Parallel GL" << endl; cout << "DisplayName = " << displname << endl; cout << "current display = " << dpy << endl; cout << "current drawable = " << drawable << endl; cout << "current context = " << ctx << endl; cout << "contextid = " << xid << endl; cout << "isdirect = " << glXIsDirect ( dpy, ctx ) << endl; cout << "extensionstring = " << glXQueryExtensionsString( dpy, 0 ) << endl; Array request(ntasks); MPI_Status status; for ( int dest = 1; dest < ntasks; dest++ ) { MyMPI_Send ("redraw", dest); MyMPI_Send ("init", dest); MyMPI_Send (displname, dest); MyMPI_Send (int (drawable), dest); MyMPI_Send (int (xid), dest); int hi; MPI_Irecv( &hi, 1, MPI_INT, dest, MPI_ANY_TAG, MPI_COMM_WORLD, &request[dest]); // MyMPI_IRecv (hi, dest, request[dest]); } for ( int dest = 1; dest < ntasks; dest++ ) { MPI_Wait(&request[dest], &status); } } } } void VisualScene :: Broadcast () { if (ntasks == 1) return; if (id == 0) { for (int dest = 1; dest < ntasks; dest++) { MyMPI_Send ("redraw", dest); MyMPI_Send ("broadcast", dest); } } MyMPI_Bcast (selface); vssolution.Broadcast (); } #endif /* *********************** Draw 2D Geometry **************** */ VisualSceneGeometry2d :: VisualSceneGeometry2d () : VisualScene() { ; } VisualSceneGeometry2d :: ~VisualSceneGeometry2d () { ; } void VisualSceneGeometry2d :: DrawScene () { if (changeval != geometry2d->GetSplines().Size()) BuildScene(); changeval = geometry2d->GetSplines().Size(); glClearColor(backcolor, backcolor, backcolor, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); SetLight(); // glEnable (GL_LIGHT0); glDisable (GL_LIGHTING); glPushMatrix(); glMultMatrixf (transformationmat); // SetClippingPlane (); glShadeModel (GL_SMOOTH); glEnable (GL_COLOR_MATERIAL); glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); // float mat_col[] = { 0, 0, 1, 1 }; // glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col); glColor3f (0, 0, 1); Array > points, otherpoints; for (int i = 1; i <= geometry2d->GetSplines().Size(); i++) { geometry2d->GetSplines().Get(i)->GetPoints (20, points); glBegin (GL_LINE_STRIP); for (int j = 0; j < points.Size(); j++) glVertex3f (points[j](0), points[j](1), 0); glEnd(); } glColor3f (1, 0, 0); for (int i = 1; i <= geometry2d->GetSplines().Size(); i++) { int other = geometry2d->GetSplines().Get(i)->copyfrom; if (other != -1) { geometry2d->GetSplines().Get(i)->GetPoints (6, points); geometry2d->GetSplines().Get(other)->GetPoints (6, otherpoints); glBegin (GL_LINES); for (int j = 1; j < 5; j++) { glVertex3f (points[j](0), points[j](1), 0); glVertex3f (otherpoints[j](0), otherpoints[j](1), 0); } glEnd (); } } glPopMatrix(); DrawCoordinateCross (); DrawNetgenLogo (); glFinish(); } void VisualSceneGeometry2d :: BuildScene (int zoomall) { Box<2> bbox; geometry2d->GetBoundingBox (bbox); Point<2> c = Center (bbox.PMin(), bbox.PMax()); center = Point3d (c(0), c(1), 0); rad = Dist (bbox.PMin(), bbox.PMax()) / 2; CalcTransformationMatrices(); } /* *********************** Draw STL Geometry **************** */ VisualSceneSTLGeometry :: VisualSceneSTLGeometry () : VisualScene() { ; } VisualSceneSTLGeometry :: ~VisualSceneSTLGeometry () { ; } void VisualSceneSTLGeometry :: DrawScene () { if (changeval != stlgeometry->GetNT()) BuildScene(); changeval = stlgeometry->GetNT(); glClearColor(backcolor, backcolor, backcolor, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); SetLight(); glPushMatrix(); glMultMatrixf (transformationmat); glShadeModel (GL_SMOOTH); glDisable (GL_COLOR_MATERIAL); glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); double shine = vispar.shininess; // double transp = vispar.transp; glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, shine); glLogicOp (GL_COPY); float mat_col[] = { 0.2f, 0.2f, 0.8f, 1.0f}; glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col); glPolygonOffset (1, 1); glEnable (GL_POLYGON_OFFSET_FILL); glCallList (trilists.Get(1)); glDisable (GL_POLYGON_OFFSET_FILL); int showtrias = vispar.showstltrias; if (showtrias) { float mat_coll[] = { 0.2f, 0.2f, 0.2f, 1.0f }; glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_coll); glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); glCallList (trilists.Get(1)); } /* glBegin (GL_TRIANGLES); for (j = 1; j <= stlgeometry -> GetNT(); j++) { const STLTriangle & tria = stlgeometry -> GetTriangle(j); glNormal3f (tria.normal.X(), tria.normal.Y(), tria.normal.Z()); for (k = 0; k < 3; k++) { glVertex3f (tria.pts[k].X(), tria.pts[k].Y(), tria.pts[k].Z()); } } glEnd (); */ glPopMatrix(); glFinish(); } void VisualSceneSTLGeometry :: BuildScene (int zoomall) { // cout << "rebuild stl geometry scene" << endl; center = stlgeometry -> GetBoundingBox().Center(); rad = stlgeometry -> GetBoundingBox().Diam() / 2; CalcTransformationMatrices(); for (int i = 1; i <= trilists.Size(); i++) glDeleteLists (trilists.Elem(i), 1); trilists.SetSize(0); trilists.Append (glGenLists (1)); glNewList (trilists.Last(), GL_COMPILE); glEnable (GL_NORMALIZE); glBegin (GL_TRIANGLES); for (int j = 1; j <= stlgeometry -> GetNT(); j++) { const Vec3d & n = stlgeometry->GetTriangle(j).Normal(); glNormal3f (n.X(), n.Y(), n.Z()); for (int k = 1; k <= 3; k++) { const Point3d & p = stlgeometry->GetPoint (stlgeometry -> GetTriangle(j).PNum(k)); glVertex3f (p.X(),p.Y(), p.Z()); } } glEnd (); glEndList (); } VisualSceneSpecPoints :: VisualSceneSpecPoints () : VisualScene() { ; } VisualSceneSpecPoints :: ~VisualSceneSpecPoints () { ; } void VisualSceneSpecPoints :: DrawScene () { if (!mesh) { VisualScene::DrawScene(); return; } if (changeval != specpoints.Size()) BuildScene(); changeval = specpoints.Size(); glClearColor(backcolor, backcolor, backcolor, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable (GL_COLOR_MATERIAL); glColor3f (1.0f, 1.0f, 1.0f); glLineWidth (1.0f); glPushMatrix(); glMultMatrixf (transformationmat); // glEnable (GL_COLOR); // glDisable (GL_COLOR_MATERIAL); if (vispar.drawedtangents) { glColor3d (1, 0, 0); glBegin (GL_LINES); for (int i = 1; i <= specpoints.Size(); i++) { const Point3d p1 = specpoints.Get(i).p; const Point3d p2 = specpoints.Get(i).p + len * specpoints.Get(i).v; glVertex3d (p1.X(), p1.Y(), p1.Z()); glVertex3d (p2.X(), p2.Y(), p2.Z()); } glEnd(); } if (vispar.drawededges) { glColor3d (1, 0, 0); glBegin (GL_LINES); for (int i = 1; i <= mesh->GetNSeg(); i++) { const Segment & seg = mesh -> LineSegment (i); glVertex3dv ( (*mesh)[seg[0]] ); glVertex3dv ( (*mesh)[seg[1]] ); // glVertex3dv ( &(*mesh)[seg[0]].X() ); // glVertex3dv ( &(*mesh)[seg[1]].X() ); } glEnd(); } glColor3d (1, 0, 0); glBegin (GL_LINES); for (int i = 0; i < boxes.Size(); i++) { glVertex3dv ( boxes[i].PMin() ); glVertex3dv ( boxes[i].PMax() ); } glEnd(); if (vispar.drawededgenrs) { glEnable (GL_COLOR_MATERIAL); GLfloat textcol[3] = { 1 - backcolor, 1 - backcolor, 1 - backcolor }; glColor3fv (textcol); glNormal3d (0, 0, 1); glPushAttrib (GL_LIST_BIT); // glListBase (fontbase); char buf[20]; for (int i = 1; i <= mesh->GetNSeg(); i++) { const Segment & seg = mesh -> LineSegment (i); const Point3d p1 = mesh -> Point (seg[0]); const Point3d p2 = mesh -> Point (seg[1]); const Point3d p = Center (p1, p2); glRasterPos3d (p.X(), p.Y(), p.Z()); sprintf (buf, "%d", seg.edgenr); // glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf); MyOpenGLText (buf); } glPopAttrib (); glDisable (GL_COLOR_MATERIAL); } if (vispar.drawedpoints) { glColor3d (0, 0, 1); /* glPointSize( 3.0 ); float range[2]; glGetFloatv(GL_POINT_SIZE_RANGE, &range[0]); cout << "max ptsize = " << range[0] << "-" << range[1] << endl; glBegin( GL_POINTS ); for (int i = 1; i <= mesh -> GetNP(); i++) { const Point3d & p = mesh -> Point(i); if (i % 2) glVertex3f( p.X(), p.Y(), p.Z()); } glEnd(); */ static GLubyte knoedel[] = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, }; glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glDisable (GL_COLOR_MATERIAL); glDisable (GL_LIGHTING); glDisable (GL_CLIP_PLANE0); for (int i = 1; i <= mesh -> GetNP(); i++) { const Point3d & p = mesh -> Point(i); glRasterPos3d (p.X(), p.Y(), p.Z()); glBitmap (7, 7, 3, 3, 0, 0, &knoedel[0]); } } if (vispar.drawedpointnrs) { glEnable (GL_COLOR_MATERIAL); GLfloat textcol[3] = { 1 - backcolor, 1 - backcolor, 1 - backcolor }; glColor3fv (textcol); glNormal3d (0, 0, 1); glPushAttrib (GL_LIST_BIT); // glListBase (fontbase); char buf[20]; for (int i = 1; i <= mesh->GetNP(); i++) { const Point3d & p = mesh->Point(i); glRasterPos3d (p.X(), p.Y(), p.Z()); sprintf (buf, "%d", i); // glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf); MyOpenGLText (buf); } glPopAttrib (); glDisable (GL_COLOR_MATERIAL); } glPopMatrix(); if (vispar.drawcoordinatecross) DrawCoordinateCross (); DrawNetgenLogo (); glFinish(); } void VisualSceneSpecPoints :: BuildScene (int zoomall) { if (!mesh) { VisualScene::BuildScene(zoomall); return; } Box3d box; if (mesh->GetNSeg()) { box.SetPoint (mesh->Point (mesh->LineSegment(1)[0])); for (int i = 1; i <= mesh->GetNSeg(); i++) { box.AddPoint (mesh->Point (mesh->LineSegment(i)[0])); box.AddPoint (mesh->Point (mesh->LineSegment(i)[1])); } } else if (specpoints.Size() >= 2) { box.SetPoint (specpoints.Get(1).p); for (int i = 2; i <= specpoints.Size(); i++) box.AddPoint (specpoints.Get(i).p); } else { box = Box3d (Point3d (0,0,0), Point3d (1,1,1)); } if (zoomall == 2 && ((vispar.centerpoint >= 1 && vispar.centerpoint <= mesh->GetNP()) || vispar.use_center_coords)) { if (vispar.use_center_coords) { center.X() = vispar.centerx; center.Y() = vispar.centery; center.Z() = vispar.centerz; } else center = mesh->Point (vispar.centerpoint); } else center = Center (box.PMin(), box.PMax()); rad = 0.5 * Dist (box.PMin(), box.PMax()); CalcTransformationMatrices(); } } netgen-4.9.13/libsrc/visualization/visual.hpp0000644000175000001440000000127511244263332016205 00000000000000#ifndef FILE_VISUAL #define FILE_VISUAL /* *************************************************************************/ /* File: visual.hpp */ /* Author: Joachim Schoeberl */ /* Date: 02. Dec. 01 */ /* *************************************************************************/ /* Visualization */ #ifdef PARALLEL #define PARALLELGL #endif #include "../include/incvis.hpp" #include "vispar.hpp" #include "mvdraw.hpp" #include "soldata.hpp" #include namespace netgen { #include "vssolution.hpp" #include "meshdoc.hpp" } #endif netgen-4.9.13/libsrc/visualization/vsmesh.cpp0000644000175000001440000031267611343730640016215 00000000000000#ifndef NOTCL #include #include #include #include #include // #include #include namespace netgen { extern AutoPtr mesh; extern STLGeometry * stlgeometry; VisualSceneMesh vsmesh; VisualSceneMesh :: VisualSceneMesh () : VisualScene() { filledlist = 0; linelist = 0; edgelist = 0; badellist = 0; tetlist = 0; prismlist = 0; hexlist = 0; pyramidlist = 0; identifiedlist = 0; pointnumberlist = 0; domainsurflist = 0; vstimestamp = GetTimeStamp(); selecttimestamp = GetTimeStamp(); filledtimestamp = GetTimeStamp(); linetimestamp = GetTimeStamp(); edgetimestamp = GetTimeStamp(); pointnumbertimestamp = GetTimeStamp(); tettimestamp = GetTimeStamp(); prismtimestamp = GetTimeStamp(); hextimestamp = GetTimeStamp(); pyramidtimestamp = GetTimeStamp(); badeltimestamp = GetTimeStamp(); identifiedtimestamp = GetTimeStamp(); domainsurftimestamp = GetTimeStamp(); selface = -1; selelement = -1; locpi = 1; selpoint = -1; selpoint2 = -1; seledge = -1; minh = 0.0; maxh = 0.0; } VisualSceneMesh :: ~VisualSceneMesh () { ; } void VisualSceneMesh :: DrawScene () { if (!mesh) { VisualScene::DrawScene(); return; } lock = NULL; clock_t starttime, endtime; starttime = clock(); BuildScene(); glClearColor(backcolor, backcolor, backcolor, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable (GL_COLOR_MATERIAL); glColor3f (1.0f, 1.0f, 1.0f); glLineWidth (1.0f); SetLight(); glPushMatrix(); glMultMatrixf (transformationmat); GLdouble projmat[16]; glGetDoublev (GL_PROJECTION_MATRIX, projmat); #ifdef PARALLEL glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); #endif glInitNames (); glPushName (0); // glEnable (GL_LINE_SMOOTH); // glEnable (GL_BLEND); // glEnable (GL_POLYGON_SMOOTH); // glDisable (GL_DEPTH_TEST); // glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // glHint (GL_LINE_SMOOTH_HINT, GL_DONT_CARE); glDisable (GL_COLOR_MATERIAL); GLfloat matcol0[] = { 0, 0, 0, 1 }; GLfloat matcol1[] = { 1, 1, 1, 1 }; GLfloat matcolf[] = { 0, 1, 0, 1 }; GLfloat matcolb[] = { 0.5, 0, 0, 1 }; // GLfloat matcolblue[] = { 0, 0, 1, 1 }; glMatrixMode (GL_MODELVIEW); glMaterialfv(GL_FRONT, GL_EMISSION, matcol0); glMaterialfv(GL_BACK, GL_EMISSION, matcol0); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, matcol1); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, matcolf); glMaterialfv(GL_BACK, GL_AMBIENT_AND_DIFFUSE, matcolb); glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); // glPolygonOffset (1,10); glPolygonOffset (2,2); glEnable (GL_POLYGON_OFFSET_FILL); SetClippingPlane (); if (vispar.drawfilledtrigs) { if (filledtimestamp < mesh->GetTimeStamp () || filledtimestamp < selecttimestamp) { BuildFilledList (); } #ifdef PARALLELGL if (ntasks > 1 && vispar.drawtetsdomain > 0 && vispar.drawtetsdomain < ntasks) glCallList (par_filledlists[vispar.drawtetsdomain]); else #endif glCallList (filledlist); } if (vispar.drawbadels) glCallList (badellist); if (vispar.drawprisms) { BuildPrismList (); glCallList (prismlist); } if (vispar.drawpyramids) { BuildPyramidList (); glCallList (pyramidlist); } if (vispar.drawhexes) { BuildHexList (); glCallList (hexlist); } if (vispar.drawtets) { BuildTetList (); glCallList (tetlist); } if (vispar.drawdomainsurf) { BuildDomainSurfList(); glCallList (domainsurflist); } glDisable (GL_POLYGON_OFFSET_FILL); // draw lines glMatrixMode (GL_MODELVIEW); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, matcol0); glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, matcol0); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, matcol0); glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); glLineWidth (1.0f); glColor3f (0.0f, 0.0f, 0.0f); glDisable (GL_LINE_SMOOTH); if (vispar.drawoutline) { glPolygonOffset (1, 1); glEnable (GL_POLYGON_OFFSET_LINE); if (linetimestamp < mesh->GetTimeStamp ()) BuildLineList (); #ifdef PARALLELGL if (ntasks > 1 && vispar.drawtetsdomain > 0 && vispar.drawtetsdomain < ntasks) // for (int dest = 1; dest < ntasks; dest++) // if (vispar.drawtetsdomain == dest) glCallList (par_linelists[vispar.drawtetsdomain]); else #endif glCallList (linelist); glDisable (GL_POLYGON_OFFSET_LINE); } if (vispar.drawidentified) { glPolygonOffset (1, -1); glEnable (GL_POLYGON_OFFSET_LINE); glCallList (identifiedlist); glDisable (GL_POLYGON_OFFSET_LINE); } if (vispar.drawpointnumbers || vispar.drawedgenumbers || vispar.drawfacenumbers || vispar.drawelementnumbers) glCallList (pointnumberlist); glPopName(); if (vispar.drawedges) { BuildEdgeList(); glCallList (edgelist); } if (selpoint > 0 && selpoint <= mesh->GetNP()) { /* glPointSize (3.0); glColor3d (0, 0, 1); glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, matcolblue); glBegin (GL_POINTS); const Point3d p = mesh->Point(selpoint); glVertex3f (p.X(), p.Y(), p.Z()); glEnd(); */ glColor3d (0, 0, 1); static GLubyte cross[] = { 0xc6, 0xee, 0x7c, 0x38, 0x7c, 0xee, 0xc6 }; glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glDisable (GL_COLOR_MATERIAL); glDisable (GL_LIGHTING); glDisable (GL_CLIP_PLANE0); const Point3d p = mesh->Point(selpoint); glRasterPos3d (p.X(), p.Y(), p.Z()); glBitmap (7, 7, 3, 3, 0, 0, &cross[0]); } glDisable(GL_CLIP_PLANE0); glPopMatrix(); if (vispar.colormeshsize) DrawColorBar (minh, maxh, 1); DrawCoordinateCross (); DrawNetgenLogo (); if (lock) { lock -> UnLock(); delete lock; lock = NULL; } glFinish(); endtime = clock(); // cout << 1.0 / (double(endtime - starttime)/CLOCKS_PER_SEC) << " frames/sec" << endl; } void VisualSceneMesh :: BuildScene (int zoomall) { if (!mesh) { VisualScene::BuildScene (zoomall); return; } if (!lock) { lock = new NgLock (mesh->Mutex()); lock -> Lock(); } int i, j; Point3d pmin, pmax; static double oldrad = 0; Array faces; int meshtimestamp = mesh->GetTimeStamp(); if (meshtimestamp > vstimestamp || zoomall) { if (mesh->GetDimension() == 2) { // works in NGSolve, mesh view mesh->GetBox (pmin, pmax); } else { // otherwise strange zooms douring mesh generation mesh->GetBox (pmin, pmax, SURFACEPOINT); } if (vispar.use_center_coords && zoomall == 2) { center.X() = vispar.centerx; center.Y() = vispar.centery; center.Z() = vispar.centerz; } else if (selpoint >= 1 && zoomall == 2) center = mesh->Point (selpoint); else if (vispar.centerpoint >= 1 && zoomall == 2) center = mesh->Point (vispar.centerpoint); else center = Center (pmin, pmax); rad = 0.5 * Dist (pmin, pmax); if(rad == 0) rad = 1e-6; if (rad > 1.2 * oldrad || mesh->GetMajorTimeStamp() > vstimestamp || zoomall) { CalcTransformationMatrices(); oldrad = rad; } } glEnable (GL_NORMALIZE); if (pointnumberlist) { glDeleteLists (pointnumberlist, 1); pointnumberlist = 0; } if (badellist) { glDeleteLists (badellist, 1); badellist = 0; } /* if (prismlist) { glDeleteLists (prismlist, 1); prismlist = 0; } if (pyramidlist) { glDeleteLists (pyramidlist, 1); pyramidlist = 0; } if (hexlist) { glDeleteLists (hexlist, 1); hexlist = 0; } */ if (identifiedlist) { glDeleteLists (identifiedlist, 1); identifiedlist = 0; } pointnumberlist = glGenLists (1); glNewList (pointnumberlist, GL_COMPILE); if (vispar.drawpointnumbers || vispar.drawedgenumbers || vispar.drawfacenumbers || vispar.drawelementnumbers) { // glEnable (GL_COLOR_MATERIAL); GLfloat textcol[3] = { 1 - backcolor, 1 - backcolor, 1 - backcolor }; glColor3fv (textcol); glNormal3d (0, 0, 1); glPushAttrib (GL_LIST_BIT); // glListBase (fontbase); char buf[30]; if (vispar.drawpointnumbers) for (i = 1; i <= mesh->GetNP(); i++) { const Point3d & p = mesh->Point(i); glRasterPos3d (p.X(), p.Y(), p.Z()); sprintf (buf, "%d", i); // glCallLists (strlen (buf), GL_UNSIGNED_BYTE, buf); MyOpenGLText (buf); } if (vispar.drawedgenumbers) { /* for (SegmentIndex i = 0; i < mesh->GetNSeg(); i++) { const Segment & seg = (*mesh)[i]; const Point3d & p1 = mesh->Point(seg[0]); const Point3d & p2 = mesh->Point(seg[1]); const Point3d p = Center (p1, p2); glRasterPos3d (p.X(), p.Y(), p.Z()); sprintf (buf, "%d", seg.edgenr); glCallLists (strlen (buf), GL_UNSIGNED_BYTE, buf); } */ const MeshTopology & top = mesh->GetTopology(); for (i = 1; i <= top.GetNEdges(); i++) { int v1, v2; top.GetEdgeVertices (i, v1, v2); const Point3d & p1 = mesh->Point(v1); const Point3d & p2 = mesh->Point(v2); const Point3d p = Center (p1, p2); glRasterPos3d (p.X(), p.Y(), p.Z()); sprintf (buf, "%d", i); // glCallLists (strlen (buf), GL_UNSIGNED_BYTE, buf); MyOpenGLText (buf); } } if (vispar.drawfacenumbers) { const MeshTopology & top = mesh->GetTopology(); Array v; for (i = 1; i <= top.GetNFaces(); i++) { top.GetFaceVertices (i, v); const Point3d & p1 = mesh->Point(v.Elem(1)); const Point3d & p2 = mesh->Point(v.Elem(2)); const Point3d & p3 = mesh->Point(v.Elem(3)); Point3d p; if (v.Elem(4) == 0) { p = Center (p1, p2, p3); } else { const Point3d & p4 = mesh->Point(v.Elem(4)); Point3d hp1 = Center (p1, p2); Point3d hp2 = Center (p3, p4); p = Center (hp1, hp2); } glRasterPos3d (p.X(), p.Y(), p.Z()); sprintf (buf, "%d", i); // glCallLists (strlen (buf), GL_UNSIGNED_BYTE, buf); MyOpenGLText (buf); } } if (vispar.drawelementnumbers) { Array v; for (i = 1; i <= mesh->GetNE(); i++) { // const ELEMENTTYPE & eltype = mesh->ElementType(i); Array pnums; Point3d p; const Element & el = mesh->VolumeElement (i); if ( ! el.PNum(5)) // eltype == TET ) { pnums.SetSize(4); for( int j = 0; j < pnums.Size(); j++) pnums[j] = mesh->VolumeElement(i).PNum(j+1); const Point3d & p1 = mesh->Point(pnums[0]); const Point3d & p2 = mesh->Point(pnums[1]); const Point3d & p3 = mesh->Point(pnums[2]); const Point3d & p4 = mesh->Point(pnums[3]); p = Center (p1, p2, p3, p4); } else if ( ! el.PNum(6)) // eltype == PYRAMID { pnums.SetSize(5); for( int j = 0; j < pnums.Size(); j++) pnums[j] = mesh->VolumeElement(i).PNum(j+1); const Point3d & p1 = mesh->Point(pnums[0]); const Point3d & p2 = mesh->Point(pnums[1]); const Point3d & p3 = mesh->Point(pnums[2]); const Point3d & p4 = mesh->Point(pnums[3]); const Point3d & p5 = mesh->Point(pnums[4]); p.X() = 0.3 * p5.X() + 0.7 * Center ( Center(p1, p3) , Center(p2, p4) ) . X(); p.Y() = 0.3 * p5.Y() + 0.7 * Center ( Center(p1, p3) , Center(p2, p4) ) . Y(); p.Z() = 0.3 * p5.Z() + 0.7 * Center ( Center(p1, p3) , Center(p2, p4) ) . Z(); } else if ( ! el.PNum(7) ) // eltype == PRISM { pnums.SetSize(6); for( int j = 0; j < pnums.Size(); j++) pnums[j] = mesh->VolumeElement(i).PNum(j+1); const Point3d & p1 = mesh->Point(pnums[0]); const Point3d & p2 = mesh->Point(pnums[1]); const Point3d & p3 = mesh->Point(pnums[2]); const Point3d & p11 = mesh->Point(pnums[3]); const Point3d & p12 = mesh->Point(pnums[4]); const Point3d & p13 = mesh->Point(pnums[5]); p = Center ( Center (p1, p2, p3) , Center(p11, p12, p13) ) ; } else if (! el.PNum(9) ) // eltype == HEX { pnums.SetSize(8); for( int j = 0; j < pnums.Size(); j++) pnums[j] = mesh->VolumeElement(i).PNum(j+1); const Point3d & p1 = mesh->Point(pnums[0]); const Point3d & p2 = mesh->Point(pnums[1]); const Point3d & p3 = mesh->Point(pnums[2]); const Point3d & p4 = mesh->Point(pnums[3]); const Point3d & p5 = mesh->Point(pnums[4]); const Point3d & p6 = mesh->Point(pnums[5]); const Point3d & p7 = mesh->Point(pnums[6]); const Point3d & p8 = mesh->Point(pnums[7]); p = Center ( Center ( Center(p1, p3), Center(p2, p4) ) , Center( Center(p5, p7) , Center(p6, p8 ) ) ); } glRasterPos3d (p.X(), p.Y(), p.Z()); sprintf (buf, "%d", i); // glCallLists (strlen (buf), GL_UNSIGNED_BYTE, buf); MyOpenGLText (buf); } } glPopAttrib (); // glDisable (GL_COLOR_MATERIAL); } glEndList (); badellist = glGenLists (1); glNewList (badellist, GL_COMPILE); if (vispar.drawbadels) { // SetClippingPlane (); static float badelcol[] = { 1.0f, 0.0f, 1.0f, 1.0f }; glLineWidth (1.0f); for (i = 1; i <= mesh->GetNE(); i++) { if (mesh->VolumeElement(i).flags.badel || mesh->VolumeElement(i).flags.illegal || (i == vispar.drawelement)) { // copy to be thread-safe Element el = mesh->VolumeElement (i); el.GetSurfaceTriangles (faces); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, badelcol); // if ( (el.GetNP() == 4) || (el.GetNP() == 10)) if (el.PNum(1)) { glBegin (GL_TRIANGLES); for (j = 1; j <= faces.Size(); j++) { Element2d & face = faces.Elem(j); const Point3d & lp1 = mesh->Point (el.PNum(face.PNum(1))); const Point3d & lp2 = mesh->Point (el.PNum(face.PNum(2))); const Point3d & lp3 = mesh->Point (el.PNum(face.PNum(3))); Vec3d n = Cross (Vec3d (lp1, lp2), Vec3d (lp1, lp3)); n /= (n.Length()+1e-12); glNormal3d (n.X(), n.Y(), n.Z()); glVertex3d (lp1.X(), lp1.Y(), lp1.Z()); glVertex3d (lp2.X(), lp2.Y(), lp2.Z()); glVertex3d (lp3.X(), lp3.Y(), lp3.Z()); } glEnd(); } } } for (i = 1; i <= mesh->GetNE(); i++) { if (mesh->VolumeElement(i).flags.badel) { // copy to be thread-safe Element el = mesh->VolumeElement (i); if ( (el.GetNP() == 4) || (el.GetNP() == 10)) { glBegin (GL_LINES); glVertex3d (0,0,0); const Point3d & p = mesh->Point(el.PNum(1)); glVertex3d (p.X(), p.Y(), p.Z()); glEnd(); } } } for (i = 1; i <= mesh->GetNE(); i++) { Element el = mesh->VolumeElement (i); int hascp = 0; for (j = 1; j <= el.GetNP(); j++) if (el.PNum(j) == vispar.centerpoint) hascp = 1; if (hascp) { (*testout) << "draw el " << i << " : "; for (j = 1; j <= el.GetNP(); j++) (*testout) << el.PNum(j) << " "; (*testout) << endl; if (el.GetNP() == 4) { int et[6][2] = { { 1, 2 }, { 1, 3 }, { 1, 4 }, { 2, 3 }, { 2, 4 }, { 3, 4 } } ; for (j = 0; j < 6; j++) { glBegin (GL_LINES); const Point3d & p1 = mesh->Point (el.PNum(et[j][0])); const Point3d & p2 = mesh->Point (el.PNum(et[j][1])); glVertex3d (p1.X(), p1.Y(), p1.Z()); glVertex3d (p2.X(), p2.Y(), p2.Z()); glEnd (); } } if (el.GetNP() == 10) { int et[12][2] = { { 1, 5 }, { 2, 5 }, { 1, 6 }, { 3, 6 }, { 1, 7 }, { 4, 7 }, { 2, 8 }, { 3, 8 }, { 2, 9 }, { 4, 9 }, { 3, 10 }, { 4, 10 } }; for (j = 0; j < 12; j++) { glBegin (GL_LINES); const Point3d & p1 = mesh->Point (el.PNum(et[j][0])); const Point3d & p2 = mesh->Point (el.PNum(et[j][1])); glVertex3d (p1.X(), p1.Y(), p1.Z()); glVertex3d (p2.X(), p2.Y(), p2.Z()); glEnd (); } } } } for (i = 1; i <= mesh->GetNSE(); i++) { Element2d el = mesh->SurfaceElement(i); if (!el.BadElement()) continue; int drawel = 1; for (j = 1; j <= el.GetNP(); j++) if (!el.PNum(j)) drawel = 0; if (!drawel) continue; cout << int (el.GetType()) << " " << flush; switch (el.GetType()) { case TRIG: { glBegin (GL_TRIANGLES); Point3d lp1 = mesh->Point (el.PNum(1)); Point3d lp2 = mesh->Point (el.PNum(2)); Point3d lp3 = mesh->Point (el.PNum(3)); Vec3d n = Cross (Vec3d (lp1, lp2), Vec3d (lp1, lp3)); n /= (n.Length() + 1e-12); glNormal3dv (&n.X()); glVertex3dv (&lp1.X()); glVertex3dv (&lp2.X()); glVertex3dv (&lp3.X()); glEnd(); break; } case QUAD: { glBegin (GL_QUADS); const Point3d & lp1 = mesh->Point (el.PNum(1)); const Point3d & lp2 = mesh->Point (el.PNum(2)); const Point3d & lp3 = mesh->Point (el.PNum(4)); const Point3d & lp4 = mesh->Point (el.PNum(3)); Vec3d n = Cross (Vec3d (lp1, lp2), Vec3d (lp1, Center (lp3, lp4))); n /= (n.Length() + 1e-12); glNormal3d (n.X(), n.Y(), n.Z()); glVertex3d (lp1.X(), lp1.Y(), lp1.Z()); glVertex3d (lp2.X(), lp2.Y(), lp2.Z()); glVertex3d (lp4.X(), lp4.Y(), lp4.Z()); glVertex3d (lp3.X(), lp3.Y(), lp3.Z()); glEnd(); break; } case TRIG6: { int lines[6][2] = { { 1, 6 }, { 2, 6 }, { 1, 5 }, { 3, 5 }, { 2, 4 }, { 3, 4 } }; glBegin (GL_LINES); for (j = 0; j < 6; j++) { glVertex3dv ( mesh->Point (el.PNum(lines[j][0])) ); glVertex3dv ( mesh->Point (el.PNum(lines[j][0])) ); } glEnd(); break; } case QUAD6: { int lines[6][2] = { { 1, 5 }, { 2, 5 }, { 3, 6 }, { 4, 6 }, { 1, 4 }, { 2, 3 } }; glBegin (GL_LINES); for (j = 0; j < 6; j++) { const Point3d & lp1 = mesh->Point (el.PNum(lines[j][0])); const Point3d & lp2 = mesh->Point (el.PNum(lines[j][1])); glVertex3d (lp1.X(), lp1.Y(), lp1.Z()); glVertex3d (lp2.X(), lp2.Y(), lp2.Z()); } glEnd (); break; } default: PrintSysError ("Cannot draw surface element of type ", int(el.GetType())); } } glLoadName (0); } glEndList (); if (1) { identifiedlist = glGenLists (1); glNewList (identifiedlist, GL_COMPILE); GLfloat identifiedcol[] = { 1, 0, 1, 1 }; glLineWidth (3); // for (i = 1; i <= mesh->GetNSeg(); i++) if (& mesh -> GetIdentifications() ) { INDEX_2_HASHTABLE & idpts = mesh->GetIdentifications().GetIdentifiedPoints(); if (&idpts) { for (i = 1; i <= idpts.GetNBags(); i++) for (j = 1; j <= idpts.GetBagSize(i); j++) { INDEX_2 pts; int val; idpts.GetData (i, j, pts, val); const Point3d & p1 = mesh->Point(pts.I1()); const Point3d & p2 = mesh->Point(pts.I2()); glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, identifiedcol); glBegin (GL_LINES); glVertex3f (p1.X(), p1.Y(), p1.Z()); glVertex3f (p2.X(), p2.Y(), p2.Z()); glEnd(); } } } glEndList (); } if (lock) { lock -> UnLock(); delete lock; lock = NULL; } vstimestamp = meshtimestamp; } void VisualSceneMesh :: BuildFilledList() { static int timer = NgProfiler::CreateTimer ("Mesh::BuildFilledList"); NgProfiler::RegionTimer reg (timer); // cout << "buildilled" << endl; #ifdef PARALLELGL cout << "buildfillelist, id = " << id << ", nse = " << mesh -> GetNSE() << endl; if (id == 0 && ntasks > 1) { InitParallelGL(); par_filledlists.SetSize (ntasks); for ( int dest = 1; dest < ntasks; dest++ ) { MyMPI_Send ("redraw", dest); MyMPI_Send ("filledlist", dest); } for ( int dest = 1; dest < ntasks; dest++ ) { MyMPI_Recv (par_filledlists[dest], dest); cout << "proc " << dest << " has drawn to list " << par_filledlists[dest] << endl; } if (filledlist) glDeleteLists (filledlist, 1); filledlist = glGenLists (1); glNewList (filledlist, GL_COMPILE); for ( int dest = 1; dest < ntasks; dest++ ) glCallList (par_filledlists[dest]); glEndList(); filledtimestamp = NextTimeStamp(); return; } #endif // clock_t starttime, endtime; // starttime = clock(); if (!lock) { lock = new NgLock (mesh->Mutex()); lock -> Lock(); } filledtimestamp = NextTimeStamp(); if (filledlist) glDeleteLists (filledlist, 1); filledlist = glGenLists (1); glNewList (filledlist, GL_COMPILE); // cout << "I am p " << id << " and got filledlist " << filledlist << endl; bool checkvicinity = (stlgeometry != NULL) && stldoctor.showvicinity; glEnable (GL_NORMALIZE); glLineWidth (1.0f); Vector locms; if (vispar.colormeshsize) { glEnable (GL_COLOR_MATERIAL); glShadeModel (GL_SMOOTH); locms.SetSize (mesh->GetNP()); maxh = -1; minh = 1e99; for (int i = 1; i <= locms.Size(); i++) { Point3d p = mesh->Point(i); locms(i-1) = mesh->GetH (p); if (locms(i-1) > maxh) maxh = locms(i-1); if (locms(i-1) < minh) minh = locms(i-1); } if (!locms.Size()) { minh = 1; maxh = 10; } } else glDisable (GL_COLOR_MATERIAL); GLfloat matcol[] = { 0, 1, 0, 1 }; GLfloat matcolsel[] = { 1, 0, 0, 1 }; #ifdef PARALLEL GLfloat mat_coll_transp[] = { 0, 1, 0, 0.3 }; GLfloat mat_coll_transp_sel[] = { 1, 0, 0, 0.3 }; #endif CurvedElements & curv = mesh->GetCurvedElements(); int hoplotn = 1 << vispar.subdivisions; for (int col = 1; col <= 2; col++) { if (col == 2) glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, matcolsel); else glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, matcol); for (SurfaceElementIndex sei = 0; sei < mesh->GetNSE(); sei++) { const Element2d & el = (*mesh)[sei]; #ifdef PARALLEL if ( el.IsGhost() ) { if ( col == 2 ) glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_coll_transp_sel); else glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_coll_transp); } else { if (col == 2) glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, matcolsel); else glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, matcol); } #endif // Philippose - 06/07/2009 // Modified the colour system to integrate the face colours into // the mesh data structure, rather than limit it to the OCC geometry // structure... allows other geometry types to use face colours too if(col == 1) { matcol[0] = mesh->GetFaceDescriptor(el.GetIndex()).SurfColour().X(); matcol[1] = mesh->GetFaceDescriptor(el.GetIndex()).SurfColour().Y(); matcol[2] = mesh->GetFaceDescriptor(el.GetIndex()).SurfColour().Z(); matcol[3] = 1.0; glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, matcol); } bool drawel = !el.IsDeleted(); if (checkvicinity) for (int j = 0; j < el.GetNP(); j++) if (!stlgeometry->Vicinity(el.GeomInfoPi(j+1).trignum)) drawel = 0; if (!drawel) continue; if (vispar.colormeshsize && col == 2) continue; if (!vispar.colormeshsize && (col == 2) != (el.GetIndex() == selface)) continue; glLoadName (sei+1); switch (el.GetType()) { case TRIG: { if (curv.IsHighOrder()) // && curv.IsSurfaceElementCurved(sei)) { if (hoplotn > 128) hoplotn = 128; Point<3> xa[129]; Vec<3> na[129]; for (int i = 0; i < hoplotn; i++) { glBegin (GL_TRIANGLE_STRIP); for (int j = 0; j <= hoplotn-i; j++) for (int k = 0; k < 2; k++) { if (j == hoplotn-i && k == 1) continue; if (i > 0 && k == 0) { glNormal3dv (na[j]); glVertex3dv (xa[j]); continue; } Point<2> xref (double(j) / hoplotn, double(i+k) / hoplotn); Point<3> xglob; Mat<3,2> dxdxi; Vec<3> dx, dy, n; curv.CalcSurfaceTransformation (xref, sei, xglob, dxdxi); for (int i = 0; i < 3; i++) { dx(i) = dxdxi(i,0); dy(i) = dxdxi(i,1); } n = Cross (dx, dy); glNormal3dv (n); glVertex3dv (xglob); if (k == 1) { na[j] = n; xa[j] = xglob; } } glEnd(); } } else // not high order { glBegin (GL_TRIANGLES); const Point<3> & lp0 = (*mesh) [el[0]]; const Point<3> & lp1 = (*mesh) [el[1]]; const Point<3> & lp2 = (*mesh) [el[2]]; Vec<3> n = Cross (lp1-lp0, lp2-lp0).Normalize(); glNormal3dv (n); if (vispar.colormeshsize) { SetOpenGlColor (locms(el[0]-1), minh, maxh, 0); glVertex3dv (lp0); SetOpenGlColor (locms(el[1]-1), minh, maxh, 0); glVertex3dv (lp1); SetOpenGlColor (locms(el[2]-1), minh, maxh, 0); glVertex3dv (lp2); } else { glVertex3dv (lp0); glVertex3dv (lp1); glVertex3dv (lp2); } glEnd(); } break; } case QUAD: { // cout << "BuildFilledList: QUAD" << endl; // CurvedElements & curv = mesh->GetCurvedElements(); if (curv.IsHighOrder()) // && curv.IsSurfaceElementCurved(sei)) { Point<2> xr[4]; Point<3> xg; Vec<3> dx, dy, n; glBegin (GL_QUADS); for (int i = 0; i < hoplotn; i++) for (int j = 0; j < hoplotn; j++) { xr[0](0) = (double) i/hoplotn; xr[0](1) = (double) j/hoplotn; xr[1](0) = (double)(i+1)/hoplotn; xr[1](1) = (double) j/hoplotn; xr[2](0) = (double)(i+1)/hoplotn; xr[2](1) = (double)(j+1)/hoplotn; xr[3](0) = (double) i/hoplotn; xr[3](1) = (double)(j+1)/hoplotn; for (int l=0; l<4; l++) { Mat<3,2> dxdxi; curv.CalcSurfaceTransformation (xr[l], sei, xg, dxdxi); for (int i = 0; i < 3; i++) { dx(i) = dxdxi(i,0); dy(i) = dxdxi(i,1); } n = Cross (dx, dy); n.Normalize(); glNormal3d (n(0), n(1), n(2)); glVertex3d (xg(0), xg(1), xg(2)); } } glEnd(); } else // not high order { glBegin (GL_QUADS); const Point<3> & lp1 = mesh->Point (el.PNum(1)); const Point<3> & lp2 = mesh->Point (el.PNum(2)); const Point<3> & lp3 = mesh->Point (el.PNum(4)); const Point<3> & lp4 = mesh->Point (el.PNum(3)); Vec<3> n = Cross (lp2-lp1, Center (lp3, lp4)-lp1); n.Normalize(); glNormal3dv (n); glVertex3dv (lp1); glVertex3dv (lp2); glVertex3dv (lp4); glVertex3dv (lp3); glEnd (); } break; } case TRIG6: { glBegin (GL_TRIANGLES); static int trigs[4][3] = { { 1, 6, 5 }, { 2, 4, 6 }, { 3, 5, 4 }, { 4, 5, 6 } }; for (int j = 0; j < 4; j++) { const Point<3> & lp1 = mesh->Point (el.PNum(trigs[j][0])); const Point<3> & lp2 = mesh->Point (el.PNum(trigs[j][1])); const Point<3> & lp3 = mesh->Point (el.PNum(trigs[j][2])); // Vec3d n = Cross (Vec3d (lp1, lp2), Vec3d (lp1, lp3)); Vec<3> n = Cross (lp2-lp1, lp3-lp1); glNormal3dv (n); glVertex3dv (lp1); glVertex3dv (lp2); glVertex3dv (lp3); } glEnd(); break; } case QUAD6: { glBegin (GL_QUADS); static int quads[2][4] = { { 1, 5, 6, 4 }, { 5, 2, 3, 6 } }; for (int j = 0; j < 2; j++) { Point3d lp1 = mesh->Point (el.PNum(quads[j][0])); Point3d lp2 = mesh->Point (el.PNum(quads[j][1])); Point3d lp3 = mesh->Point (el.PNum(quads[j][2])); Point3d lp4 = mesh->Point (el.PNum(quads[j][3])); Vec3d n = Cross (Vec3d (lp1, lp2), Vec3d (lp1, lp3)); n /= (n.Length() + 1e-12); glNormal3dv (&n.X()); glVertex3dv (&lp1.X()); glVertex3dv (&lp2.X()); glVertex3dv (&lp3.X()); glVertex3dv (&lp4.X()); } glEnd(); break; } case QUAD8: { glBegin (GL_TRIANGLES); static int boundary[] = { 1, 5, 2, 8, 3, 6, 4, 7, 1 }; Point3d c(0,0,0); for (int j = 0; j < 4; j++) { const Point3d & hp = mesh->Point (el[j]); c.X() -= 0.25 * hp.X(); c.Y() -= 0.25 * hp.Y(); c.Z() -= 0.25 * hp.Z(); } for (int j = 4; j < 8; j++) { const Point3d & hp = mesh->Point (el[j]); c.X() += 0.5 * hp.X(); c.Y() += 0.5 * hp.Y(); c.Z() += 0.5 * hp.Z(); } for (int j = 0; j < 8; j++) { Point3d lp1 = mesh->Point (el.PNum(boundary[j])); Point3d lp2 = mesh->Point (el.PNum(boundary[j+1])); Vec3d n = Cross (Vec3d (c, lp1), Vec3d (c, lp2)); n /= (n.Length() + 1e-12); glNormal3dv (&n.X()); glVertex3dv (&lp1.X()); glVertex3dv (&lp2.X()); glVertex3dv (&c.X()); } glEnd(); break; } default: PrintSysError ("Cannot draw (2) surface element of type ", int(el.GetType())); } } } glLoadName (0); glEndList (); #ifdef PARALLELGL glFinish(); if (id > 0) MyMPI_Send (filledlist, 0); #endif // endtime = clock(); // cout << "BuildFillList time = " << double(endtime - starttime)/CLOCKS_PER_SEC << endl; } void VisualSceneMesh :: BuildLineList() { static int timer = NgProfiler::CreateTimer ("Mesh::BuildLineList"); NgProfiler::RegionTimer reg (timer); #ifdef PARALLELGL if (id == 0 && ntasks > 1) { InitParallelGL(); par_linelists.SetSize (ntasks); for ( int dest = 1; dest < ntasks; dest++ ) { MyMPI_Send ("redraw", dest); MyMPI_Send ("linelist", dest); } for ( int dest = 1; dest < ntasks; dest++ ) MyMPI_Recv (par_linelists[dest], dest); if (linelist) glDeleteLists (linelist, 1); linelist = glGenLists (1); glNewList (linelist, GL_COMPILE); for ( int dest = 1; dest < ntasks; dest++ ) glCallList (par_linelists[dest]); glEndList(); linetimestamp = NextTimeStamp(); return; } #endif if (!lock) { lock = new NgLock (mesh->Mutex()); lock -> Lock(); } linetimestamp = NextTimeStamp(); bool checkvicinity = (stlgeometry != NULL) && stldoctor.showvicinity; if (linelist) glDeleteLists (linelist, 1); linelist = glGenLists (1); glNewList (linelist, GL_COMPILE); // cout << "linelist = " << linelist << endl; glLineWidth (1.0f); int hoplotn = 1 << vispar.subdivisions; // PrintMessage (3, "nse = ", mesh->GetNSE()); for (SurfaceElementIndex sei = 0; sei < mesh->GetNSE(); sei++) { const Element2d & el = (*mesh)[sei]; bool drawel = !el.IsDeleted(); if (checkvicinity) for (int j = 0; j < el.GetNP(); j++) if (!stlgeometry->Vicinity(el.GeomInfoPi(j+1).trignum)) drawel = 0; if (!drawel) continue; switch (el.GetType()) { case TRIG: { CurvedElements & curv = mesh->GetCurvedElements(); if (curv.IsHighOrder()) // && curv.IsSurfaceElementCurved(sei)) { Point<3> xg; glBegin (GL_LINE_LOOP); for (int i = 0; i < hoplotn; i++) { Point<2> xr (double(i) / hoplotn, 0); curv.CalcSurfaceTransformation (xr, sei, xg); glVertex3dv (xg); } for (int i = 0; i < hoplotn; i++) { Point<2> xr (double(hoplotn-i) / hoplotn, double(i)/hoplotn); curv.CalcSurfaceTransformation (xr, sei, xg); glVertex3dv (xg); } for (int i = 0; i < hoplotn; i++) { Point<2> xr (0, double(hoplotn-i) / hoplotn); curv.CalcSurfaceTransformation (xr, sei, xg); glVertex3dv (xg); } glEnd(); } else { glBegin (GL_TRIANGLES); const Point<3> & lp0 = (*mesh) [el[0]]; const Point<3> & lp1 = (*mesh) [el[1]]; const Point<3> & lp2 = (*mesh) [el[2]]; glVertex3dv (lp0); glVertex3dv (lp1); glVertex3dv (lp2); glEnd(); } break; } case QUAD: { CurvedElements & curv = mesh->GetCurvedElements(); if (curv.IsHighOrder()) // && curv.IsSurfaceElementCurved(sei)) { Point<2> xr; Point<3> xg; glBegin (GL_LINE_STRIP); for (int side = 0; side < 4; side++) { for (int i = 0; i <= hoplotn; i++) { switch (side) { case 0: xr(0) = (double) i/hoplotn; xr(1) = 0.; break; case 1: xr(0) = 1.; xr(1) = (double) i/hoplotn; break; case 2: xr(0) = (double) (hoplotn-i)/hoplotn; xr(1) = 1.; break; case 3: xr(0) = 0.; xr(1) = (double) (hoplotn-i)/hoplotn; break; } curv.CalcSurfaceTransformation (xr, sei, xg); glVertex3d (xg(0), xg(1), xg(2)); } } glEnd(); } else { glBegin (GL_QUADS); const Point3d & lp1 = mesh->Point (el.PNum(1)); const Point3d & lp2 = mesh->Point (el.PNum(2)); const Point3d & lp3 = mesh->Point (el.PNum(4)); const Point3d & lp4 = mesh->Point (el.PNum(3)); Vec3d n = Cross (Vec3d (lp1, lp2), Vec3d (lp1, Center (lp3, lp4))); glNormal3d (n.X(), n.Y(), n.Z()); glVertex3d (lp1.X(), lp1.Y(), lp1.Z()); glVertex3d (lp2.X(), lp2.Y(), lp2.Z()); glVertex3d (lp4.X(), lp4.Y(), lp4.Z()); glVertex3d (lp3.X(), lp3.Y(), lp3.Z()); glEnd(); } break; } case TRIG6: { int lines[6][2] = { { 1, 6 }, { 2, 6 }, { 1, 5 }, { 3, 5 }, { 2, 4 }, { 3, 4 } }; glBegin (GL_LINES); for (int j = 0; j < 6; j++) { const Point3d & lp1 = mesh->Point (el.PNum(lines[j][0])); const Point3d & lp2 = mesh->Point (el.PNum(lines[j][1])); glVertex3d (lp1.X(), lp1.Y(), lp1.Z()); glVertex3d (lp2.X(), lp2.Y(), lp2.Z()); } glEnd(); break; } case QUAD6: { int lines[6][2] = { { 1, 5 }, { 2, 5 }, { 3, 6 }, { 4, 6 }, { 1, 4 }, { 2, 3 } }; glBegin (GL_LINES); for (int j = 0; j < 6; j++) { const Point3d & lp1 = mesh->Point (el.PNum(lines[j][0])); const Point3d & lp2 = mesh->Point (el.PNum(lines[j][1])); glVertex3d (lp1.X(), lp1.Y(), lp1.Z()); glVertex3d (lp2.X(), lp2.Y(), lp2.Z()); } glEnd (); break; } case QUAD8: { int lines[8][2] = { { 1, 5 }, { 2, 5 }, { 3, 6 }, { 4, 6 }, { 1, 7 }, { 4, 7 }, { 2, 8 }, { 3, 8 } }; glBegin (GL_LINES); for (int j = 0; j < 8; j++) { const Point3d & lp1 = mesh->Point (el.PNum(lines[j][0])); const Point3d & lp2 = mesh->Point (el.PNum(lines[j][1])); glVertex3d (lp1.X(), lp1.Y(), lp1.Z()); glVertex3d (lp2.X(), lp2.Y(), lp2.Z()); } glEnd (); break; } default: PrintSysError ("Cannot draw (4) surface element of type ", int(el.GetType())); } } glEndList (); #ifdef PARALLELGL glFinish(); if (id > 0) MyMPI_Send (linelist, 0); #endif } void VisualSceneMesh :: BuildEdgeList() { if (!lock) { lock = new NgLock (mesh->Mutex()); lock -> Lock(); } if (edgetimestamp > mesh->GetTimeStamp () && vispar.shrink == 1) return; edgetimestamp = NextTimeStamp(); if (edgelist) glDeleteLists (edgelist, 1); edgelist = glGenLists (1); glNewList (edgelist, GL_COMPILE); GLfloat matcoledge[] = { 0, 0, 1, 1 }; GLfloat matcolsingedge[] = { 1, 0, 1, 1 }; glEnable (GL_POLYGON_OFFSET_LINE); glPolygonOffset (1, -1); glEnable (GL_COLOR_MATERIAL); glDisable (GL_LIGHTING); for (int i = 1; i <= mesh->GetNSeg(); i++) { const Segment & seg = mesh->LineSegment(i); const Point3d & p1 = (*mesh)[seg[0]]; const Point3d & p2 = (*mesh)[seg[1]]; if (seg.singedge_left || seg.singedge_right) glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, matcolsingedge); else glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, matcoledge); if (seg.singedge_left || seg.singedge_right) glColor3fv (matcolsingedge); else glColor3fv (matcoledge); if (seg.edgenr == seledge) glLineWidth(5); else glLineWidth(2); if (mesh->GetCurvedElements().IsHighOrder()) { int hoplotn = 1 << vispar.subdivisions; // mesh->GetCurvedElements().GetNVisualSubsecs(); Point<3> x; glBegin (GL_LINE_STRIP); for (int j = 0; j <= hoplotn; j++) { mesh->GetCurvedElements().CalcSegmentTransformation ((double) j/hoplotn, i-1, x); glVertex3d (x(0), x(1), x(2)); /* cout << "x = " << x(0) << ", " << x(1) << ", " << x(2) << ", norm = 1+" << sqrt(x(0)*x(0)+x(1)*x(1))-1 << ", phi = " << atan2(x(1), x(0))/M_PI << endl; */ } glEnd(); } else { glBegin (GL_LINES); Point<3> hp1 = p1; Point<3> hp2 = p2; Point<3> c = Center(p1, p2); if (vispar.shrink < 1) { hp1 = c + vispar.shrink * (hp1 - c); hp2 = c + vispar.shrink * (hp2 - c); } glVertex3dv (hp1); glVertex3dv (hp2); // p2.X(), p2.Y(), p2.Z()); glEnd(); } } glLineWidth (2); glDisable (GL_POLYGON_OFFSET_LINE); glDisable (GL_COLOR_MATERIAL); glEnable (GL_LIGHTING); glEndList(); } void VisualSceneMesh :: BuildPointNumberList() { ; } // Bernstein Pol B_{n,i}(x) = n! / i! / (n-i)! (1-x)^{n-i} x^i static inline double Bernstein (int n, int i, double x) { double val = 1; for (int j = 1; j <= i; j++) val *= x; for (int j = 1; j <= n-i; j++) val *= (1-x) * (j+i) / j; return val; } void ToBernstein (int order, Point<3> * pts, int stride) { static DenseMatrix mat, inv; static Vector vec1, vec2; if (mat.Height () != order+1) { mat.SetSize (order+1); inv.SetSize (order+1); vec1.SetSize (order+1); vec2.SetSize (order+1); for (int i = 0; i <= order; i++) { double x = double(i) / order; for (int j = 0; j <= order; j++) mat(i,j) = Bernstein (order, j, x); } CalcInverse (mat, inv); } for (int i = 0; i < 3; i++) { for (int j = 0; j <= order; j++) vec1(j) = pts[j*stride](i); inv.Mult (vec1, vec2); for (int j = 0; j <= order; j++) pts[j*stride](i) = vec2(j); } } void VisualSceneMesh :: BuildTetList() { if (tettimestamp > mesh->GetTimeStamp () && tettimestamp > vispar.clipplanetimestamp ) return; if (!lock) { lock = new NgLock (mesh->Mutex()); lock -> Lock(); } tettimestamp = NextTimeStamp(); if (tetlist) glDeleteLists (tetlist, 1); tetlist = glGenLists (1); glNewList (tetlist, GL_COMPILE); Vector locms; // Philippose - 16/02/2010 // Add Mesh size based coloring of // meshes also for the volume elements if (vispar.colormeshsize) { glEnable (GL_COLOR_MATERIAL); locms.SetSize (mesh->GetNP()); maxh = -1; minh = 1e99; for (int i = 1; i <= locms.Size(); i++) { Point3d p = mesh->Point(i); locms(i-1) = mesh->GetH (p); if (locms(i-1) > maxh) maxh = locms(i-1); if (locms(i-1) < minh) minh = locms(i-1); } if (!locms.Size()) { minh = 1; maxh = 10; } } else glDisable (GL_COLOR_MATERIAL); Array faces; BitArray shownode(mesh->GetNP()); if (vispar.clipenable) { shownode.Clear(); for (int i = 1; i <= shownode.Size(); i++) { Point<3> p = mesh->Point(i); double val = p[0] * clipplane[0] + p[1] * clipplane[1] + p[2] * clipplane[2] + clipplane[3]; if (val > 0) shownode.Set (i); } } else shownode.Set(); #ifdef PARALLEL static float tetcols[][8] = { { 1.0f, 1.0f, 0.0f, 1.0f }, { 1.0f, 0.0f, 0.0f, 1.0f }, { 0.0f, 1.0f, 0.0f, 1.0f }, { 0.0f, 0.0f, 1.0f, 1.0f }, { 1.0f, 1.0f, 0.0f, 0.3f }, { 1.0f, 0.0f, 0.0f, 0.3f }, { 0.0f, 1.0f, 0.0f, 0.3f }, { 0.0f, 0.0f, 1.0f, 0.3f } }; #else static float tetcols[][4] = { { 1.0f, 1.0f, 0.0f, 1.0f }, { 1.0f, 0.0f, 0.0f, 1.0f }, { 0.0f, 1.0f, 0.0f, 1.0f }, { 0.0f, 0.0f, 1.0f, 1.0f } }; #endif CurvedElements & curv = mesh->GetCurvedElements(); if (!curv.IsHighOrder()) glShadeModel (GL_FLAT); else glShadeModel (GL_SMOOTH); int hoplotn = max (2, 1 << vispar.subdivisions); for (ElementIndex ei = 0; ei < mesh->GetNE(); ei++) { if (vispar.drawtetsdomain > 0 && vispar.drawtetsdomain != (*mesh)[ei].GetIndex()) continue; const Element & el = (*mesh)[ei]; if ((el.GetType() == TET || el.GetType() == TET10) && !el.IsDeleted()) { bool drawtet = 1; for (int j = 0; j < 4; j++) if (!shownode.Test(el[j])) drawtet = 0; if (!drawtet) continue; int ind = el.GetIndex() % 4; #ifdef PARALLEL if (vispar.drawmetispartition && (el.GetPartition()!=-1)) ind = el.GetPartition() % 4; // (*testout) << "ind (" << i << ") = " << ind << endl; if ( el.IsGhost() ) { glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, tetcols[ind+4]); } else { glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, tetcols[ind]); } #else glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, tetcols[ind]); #endif if (curv.IsHighOrder()) // && curv.IsElementCurved(ei)) { const ELEMENT_FACE * faces = MeshTopology :: GetFaces1 (TET); const Point3d * vertices = MeshTopology :: GetVertices (TET); /* Point<3> grid[11][11]; Point<3> fpts[3]; int order = vispar.subdivisions+1; for (int trig = 0; trig < 4; trig++) { for (int j = 0; j < 3; j++) fpts[j] = vertices[faces[trig][j]-1]; static Point<3> c(0.25, 0.25, 0.25); if (vispar.shrink < 1) for (int j = 0; j < 3; j++) fpts[j] += (1-vispar.shrink) * (c-fpts[j]); for (int ix = 0; ix <= order; ix++) for (int iy = 0; iy <= order; iy++) { double lami[3] = { (1-double(ix)/order) * (1-double(iy)/order), ( double(ix)/order) * (1-double(iy)/order), double(iy)/order }; Point<3> xl; for (int l = 0; l < 3; l++) xl(l) = lami[0] * fpts[0](l) + lami[1] * fpts[1](l) + lami[2] * fpts[2](l); curv.CalcElementTransformation (xl, i-1, grid[ix][iy]); } for (int j = 0; j <= order; j++) ToBernstein (order, &grid[j][0], &grid[0][1]-&grid[0][0]); for (int j = 0; j <= order; j++) ToBernstein (order, &grid[0][j], &grid[1][0]-&grid[0][0]); glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, &grid[0][1](0)-&grid[0][0](0), order+1, 0.0, 1.0, &grid[1][0](0)-&grid[0][0](0), order+1, &grid[0][0](0)); glEnable(GL_MAP2_VERTEX_3); glEnable(GL_AUTO_NORMAL); glMapGrid2f(8, 0.0, 0.999, 8, 0.0, 1.0); glEvalMesh2(GL_FILL, 0, 8, 0, 8); glDisable (GL_AUTO_NORMAL); glDisable (GL_MAP2_VERTEX_3); } */ int order = curv.GetOrder(); Array > ploc ( (order+1)*(order+1) ); Array > pglob ( (order+1)*(order+1) ); Point<3> fpts[3]; for (int trig = 0; trig < 4; trig++) { for (int j = 0; j < 3; j++) fpts[j] = vertices[faces[trig][j]-1]; static Point<3> c(0.25, 0.25, 0.25); if (vispar.shrink < 1) for (int j = 0; j < 3; j++) fpts[j] += (1-vispar.shrink) * (c-fpts[j]); for (int ix = 0, ii = 0; ix <= order; ix++) for (int iy = 0; iy <= order; iy++, ii++) { double lami[3] = { (1-double(ix)/order) * (1-double(iy)/order), ( double(ix)/order) * (1-double(iy)/order), double(iy)/order }; Point<3> xl; for (int l = 0; l < 3; l++) xl(l) = lami[0] * fpts[0](l) + lami[1] * fpts[1](l) + lami[2] * fpts[2](l); ploc[ii] = xl; } curv.CalcMultiPointElementTransformation (&ploc, ei, &pglob, 0); Point<3> grid[11][11]; for (int ix = 0, ii = 0; ix <= order; ix++) for (int iy = 0; iy <= order; iy++, ii++) grid[ix][iy] = pglob[ii]; for (int j = 0; j <= order; j++) ToBernstein (order, &grid[j][0], &grid[0][1]-&grid[0][0]); for (int j = 0; j <= order; j++) ToBernstein (order, &grid[0][j], &grid[1][0]-&grid[0][0]); glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, &grid[0][1](0)-&grid[0][0](0), order+1, 0.0, 1.0, &grid[1][0](0)-&grid[0][0](0), order+1, &grid[0][0](0)); glEnable(GL_MAP2_VERTEX_3); glEnable(GL_AUTO_NORMAL); glMapGrid2f(hoplotn, 0.0, 0.9999f, hoplotn, 0.0, 1.0); glEvalMesh2(GL_FILL, 0, hoplotn, 0, hoplotn); glDisable (GL_AUTO_NORMAL); glDisable (GL_MAP2_VERTEX_3); } } else // Not High Order { Point<3> pts[4]; for (int j = 0; j < 4; j++) pts[j] = (*mesh)[el[j]]; if (vispar.shrink < 1) { Point<3> c = Center (pts[0], pts[1], pts[2], pts[3]); for (int j = 0; j < 4; j++) pts[j] = c + vispar.shrink * (pts[j]-c); } Vec<3> n; glBegin (GL_TRIANGLE_STRIP); // Philippose - 16/02/2010 // Add Mesh size based coloring of // meshes also for the volume elements if(vispar.colormeshsize) { n = Cross (pts[1]-pts[0], pts[2]-pts[0]); glNormal3dv (n); SetOpenGlColor (locms(el[0]-1), minh, maxh, 0); glVertex3dv (pts[0]); SetOpenGlColor (locms(el[1]-1), minh, maxh, 0); glVertex3dv (pts[1]); SetOpenGlColor (locms(el[2]-1), minh, maxh, 0); glVertex3dv (pts[2]); n = Cross (pts[3]-pts[1], pts[2]-pts[1]); glNormal3dv (n); SetOpenGlColor (locms(el[3]-1), minh, maxh, 0); glVertex3dv (pts[3]); n = Cross (pts[3]-pts[2], pts[0]-pts[2]); glNormal3dv (n); SetOpenGlColor (locms(el[0]-1), minh, maxh, 0); glVertex3dv (pts[0]); n = Cross (pts[1]-pts[3], pts[0]-pts[3]); glNormal3dv (n); SetOpenGlColor (locms(el[1]-1), minh, maxh, 0); glVertex3dv (pts[1]); } else // Do not color mesh based on mesh size { n = Cross (pts[1]-pts[0], pts[2]-pts[0]); glNormal3dv (n); glVertex3dv (pts[0]); glVertex3dv (pts[1]); glVertex3dv (pts[2]); n = Cross (pts[3]-pts[1], pts[2]-pts[1]); glNormal3dv (n); glVertex3dv (pts[3]); n = Cross (pts[3]-pts[2], pts[0]-pts[2]); glNormal3dv (n); glVertex3dv (pts[0]); n = Cross (pts[1]-pts[3], pts[0]-pts[3]); glNormal3dv (n); glVertex3dv (pts[1]); } glEnd(); } } } glEndList (); } void VisualSceneMesh :: BuildPrismList() { if (prismtimestamp > mesh->GetTimeStamp () && prismtimestamp > vispar.clipplanetimestamp ) return; if (!lock) { lock = new NgLock (mesh->Mutex()); lock -> Lock(); } prismtimestamp = NextTimeStamp(); if (prismlist) glDeleteLists (prismlist, 1); prismlist = glGenLists (1); glNewList (prismlist, GL_COMPILE); static float prismcol[] = { 0.0f, 1.0f, 1.0f, 1.0f }; glLineWidth (1.0f); Array faces; glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, prismcol); for (ElementIndex ei = 0; ei < mesh->GetNE(); ei++) { const Element & el = (*mesh)[ei]; if (el.GetType() == PRISM && !el.IsDeleted()) { int j; int i = ei + 1; CurvedElements & curv = mesh->GetCurvedElements(); if (curv.IsHighOrder()) // && curv.IsElementCurved(ei)) { const ELEMENT_FACE * faces = MeshTopology :: GetFaces1 (PRISM); const Point3d * vertices = MeshTopology :: GetVertices (PRISM); Point<3> grid[11][11]; Point<3> fpts[4]; int order = vispar.subdivisions+1; for (int trig = 0; trig < 2; trig++) { for (int j = 0; j < 3; j++) fpts[j] = vertices[faces[trig][j]-1]; static Point<3> c(1.0/3.0, 1.0/3.0, 0.5); if (vispar.shrink < 1) for (int j = 0; j < 3; j++) fpts[j] += (1-vispar.shrink) * (c-fpts[j]); for (int ix = 0; ix <= order; ix++) for (int iy = 0; iy <= order; iy++) { double lami[3] = { (1-double(ix)/order) * (1-double(iy)/order), ( double(ix)/order) * (1-double(iy)/order), double(iy)/order }; Point<3> xl; for (int l = 0; l < 3; l++) xl(l) = lami[0] * fpts[0](l) + lami[1] * fpts[1](l) + lami[2] * fpts[2](l); curv.CalcElementTransformation (xl, i-1, grid[ix][iy]); } for (int j = 0; j <= order; j++) ToBernstein (order, &grid[j][0], &grid[0][1]-&grid[0][0]); for (int j = 0; j <= order; j++) ToBernstein (order, &grid[0][j], &grid[1][0]-&grid[0][0]); glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, &grid[0][1](0)-&grid[0][0](0), order+1, 0.0, 1.0, &grid[1][0](0)-&grid[0][0](0), order+1, &grid[0][0](0)); glEnable(GL_MAP2_VERTEX_3); glEnable(GL_AUTO_NORMAL); glMapGrid2f(8, 0.0, 0.999f, 8, 0.0, 1.0); glEvalMesh2(GL_FILL, 0, 8, 0, 8); glDisable (GL_AUTO_NORMAL); glDisable (GL_MAP2_VERTEX_3); } for (int quad = 2; quad < 5; quad++) { for (int j = 0; j < 4; j++) fpts[j] = vertices[faces[quad][j]-1]; static Point<3> c(1.0/3.0, 1.0/3.0, 0.5); if (vispar.shrink < 1) for (int j = 0; j < 4; j++) fpts[j] += (1-vispar.shrink) * (c-fpts[j]); for (int ix = 0; ix <= order; ix++) for (int iy = 0; iy <= order; iy++) { double lami[4] = { (1-double(ix)/order) * (1-double(iy)/order), ( double(ix)/order) * (1-double(iy)/order), ( double(ix)/order) * ( double(iy)/order), (1-double(ix)/order) * ( double(iy)/order) }; Point<3> xl; for (int l = 0; l < 3; l++) xl(l) = lami[0] * fpts[0](l) + lami[1] * fpts[1](l) + lami[2] * fpts[2](l) + lami[3] * fpts[3](l); curv.CalcElementTransformation (xl, ei, grid[ix][iy]); } for (int j = 0; j <= order; j++) ToBernstein (order, &grid[j][0], &grid[0][1]-&grid[0][0]); for (int j = 0; j <= order; j++) ToBernstein (order, &grid[0][j], &grid[1][0]-&grid[0][0]); glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, &grid[0][1](0)-&grid[0][0](0), order+1, 0.0, 1.0, &grid[1][0](0)-&grid[0][0](0), order+1, &grid[0][0](0)); glEnable(GL_MAP2_VERTEX_3); glEnable(GL_AUTO_NORMAL); glMapGrid2f(8, 0.0, 1.0, 8, 0.0, 1.0); glEvalMesh2(GL_FILL, 0, 8, 0, 8); glDisable (GL_AUTO_NORMAL); glDisable (GL_MAP2_VERTEX_3); } /* int hoplotn = 1 << vispar.subdivisions; // int hoplotn = curv.GetNVisualSubsecs(); const Point3d * facepoint = MeshTopology :: GetVertices (TRIG); const ELEMENT_FACE * elface = MeshTopology :: GetFaces(TRIG); glBegin (GL_TRIANGLES); for (int trig = 0; trig<2; trig++) { Vec<3> x0,x1,d0,d1; x0 = facepoint[1] - facepoint[2]; x1 = facepoint[0] - facepoint[2]; x0.Normalize(); x1.Normalize(); if (trig == 1) swap (x0,x1); Point<3> xr[3]; Point<3> xg; Vec<3> dx, dy, dz, n; for (int i1 = 0; i1 < hoplotn; i1++) for (int j1 = 0; j1 < hoplotn-i1; j1++) for (int k = 0; k < 2; k++) { if (k == 0) { xr[0](0) = (double) i1/hoplotn; xr[0](1) = (double) j1/hoplotn; xr[1](0) = (double)(i1+1)/hoplotn; xr[1](1) = (double) j1/hoplotn; xr[2](0) = (double) i1/hoplotn; xr[2](1) = (double)(j1+1)/hoplotn; } else { if (j1 == hoplotn-i1-1) continue; xr[0](0) = (double)(i1+1)/hoplotn; xr[0](1) = (double) j1/hoplotn; xr[1](0) = (double)(i1+1)/hoplotn; xr[1](1) = (double)(j1+1)/hoplotn; xr[2](0) = (double) i1/hoplotn; xr[2](1) = (double)(j1+1)/hoplotn; }; for (int l=0; l<3; l++) { Mat<3,3> dxdxi; xr[l](2) = (double) trig; curv.CalcElementTransformation (xr[l], i-1, xg, dxdxi); for (int i = 0; i < 3; i++) { dx(i) = dxdxi(i,0); dy(i) = dxdxi(i,1); dz(i) = dxdxi(i,2); } Vec<3> d0 = x0(0)*dx + x0(1)*dy + x0(2)*dz; Vec<3> d1 = x1(0)*dx + x1(1)*dy + x1(2)*dz; n = Cross (d1, d0); glNormal3d (n(0), n(1), n(2)); glVertex3d (xg(0), xg(1), xg(2)); } } } glEnd (); glBegin (GL_QUADS); for (int quad = 0; quad<3; quad++) { const Point3d * facepoint = MeshTopology :: GetVertices (PRISM); Vec<3> x0,x1; int xyz; switch (quad) { case 0: x0 = facepoint[5] - facepoint[2]; x1 = facepoint[0] - facepoint[2]; xyz = 0; break; case 1: x0 = facepoint[4] - facepoint[0]; x1 = facepoint[1] - facepoint[0]; xyz = 0; break; case 2: x0 = facepoint[1] - facepoint[2]; x1 = facepoint[5] - facepoint[2]; xyz = 1; break; } x0.Normalize(); x1.Normalize(); swap (x0,x1); Point<3> xr[4]; Point<3> xg; Vec<3> dx, dy, dz, n; for (int i1 = 0; i1 < hoplotn; i1++) for (int j1 = 0; j1 < hoplotn; j1++) { xr[0](xyz) = (double) i1/hoplotn; xr[0](2) = (double) j1/hoplotn; xr[1](xyz) = (double)(i1+1)/hoplotn; xr[1](2) = (double) j1/hoplotn; xr[2](xyz) = (double)(i1+1)/hoplotn; xr[2](2) = (double)(j1+1)/hoplotn; xr[3](xyz) = (double) i1/hoplotn; xr[3](2) = (double)(j1+1)/hoplotn; for (int l=0; l<4; l++) { switch (quad) { case 0: xr[l](1) = 0; break; case 1: xr[l](1) = 1-xr[l](0); break; case 2: xr[l](0) = 0; break; } Mat<3,3> dxdxi; curv.CalcElementTransformation (xr[l], i-1, xg, dxdxi); for (int i = 0; i < 3; i++) { dx(i) = dxdxi(i,0); dy(i) = dxdxi(i,1); dz(i) = dxdxi(i,2); } Vec<3> d0 = x0(0)*dx + x0(1)*dy + x0(2)*dz; Vec<3> d1 = x1(0)*dx + x1(1)*dy + x1(2)*dz; n = Cross (d1, d0); glNormal3d (n(0), n(1), n(2)); glVertex3d (xg(0), xg(1), xg(2)); } } } glEnd (); */ } else { Point3d c(0,0,0); if (vispar.shrink < 1) { for (j = 1; j <= 6; j++) { Point3d p = mesh->Point(el.PNum(j)); c.X() += p.X() / 6; c.Y() += p.Y() / 6; c.Z() += p.Z() / 6; } } el.GetSurfaceTriangles (faces); glBegin (GL_TRIANGLES); for (j = 1; j <= faces.Size(); j++) { Element2d & face = faces.Elem(j); Point3d lp1 = mesh->Point (el.PNum(face.PNum(1))); Point3d lp2 = mesh->Point (el.PNum(face.PNum(2))); Point3d lp3 = mesh->Point (el.PNum(face.PNum(3))); Vec3d n = Cross (Vec3d (lp1, lp3), Vec3d (lp1, lp2)); n /= (n.Length()+1e-12); glNormal3d (n.X(), n.Y(), n.Z()); if (vispar.shrink < 1) { lp1 = c + vispar.shrink * (lp1 - c); lp2 = c + vispar.shrink * (lp2 - c); lp3 = c + vispar.shrink * (lp3 - c); } glVertex3d (lp1.X(), lp1.Y(), lp1.Z()); glVertex3d (lp2.X(), lp2.Y(), lp2.Z()); glVertex3d (lp3.X(), lp3.Y(), lp3.Z()); } glEnd(); } } } glEndList (); } void VisualSceneMesh :: BuildHexList() { if (hextimestamp > mesh->GetTimeStamp () && hextimestamp > vispar.clipplanetimestamp ) return; if (!lock) { lock = new NgLock (mesh->Mutex()); lock -> Lock(); } hextimestamp = NextTimeStamp(); if (hexlist) glDeleteLists (hexlist, 1); hexlist = glGenLists (1); glNewList (hexlist, GL_COMPILE); static float hexcol[] = { 1.0f, 1.0f, 0.0f, 1.0f }; glLineWidth (1.0f); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, hexcol); Array faces; // int hoplotn = 1 << vispar.subdivisions; for (ElementIndex ei = 0; ei < mesh->GetNE(); ei++) { const Element & el = (*mesh)[ei]; if (el.GetType() == HEX && !el.IsDeleted()) { CurvedElements & curv = mesh->GetCurvedElements(); if (curv.IsHighOrder()) // && curv.IsElementCurved(ei)) { /* // classical glBegin (GL_QUADS); const ELEMENT_FACE * faces = MeshTopology :: GetFaces (HEX); const Point3d * vertices = MeshTopology :: GetVertices (HEX); Point<3> grid[33][33]; Vec<3> gridn[33][33]; Point<3> fpts[4]; for (int quad = 0; quad<6; quad++) { for (int j = 0; j < 4; j++) fpts[j] = vertices[faces[quad][j]-1]; static Point<3> c(0.5, 0.5, 0.5); if (vispar.shrink < 1) for (int j = 0; j < 4; j++) fpts[j] += (1-vispar.shrink) * (c-fpts[j]); Vec<3> taux = fpts[1]-fpts[0]; Vec<3> tauy = fpts[3]-fpts[0]; for (int ix = 0; ix <= hoplotn; ix++) for (int iy = 0; iy <= hoplotn; iy++) { Point<3> xl; Mat<3,3> dxdxi; double lami[4] = { (1-double(ix)/hoplotn) * (1-double(iy)/hoplotn), ( double(ix)/hoplotn) * (1-double(iy)/hoplotn), ( double(ix)/hoplotn) * ( double(iy)/hoplotn), (1-double(ix)/hoplotn) * ( double(iy)/hoplotn) }; for (int l = 0; l < 3; l++) xl(l) = lami[0] * fpts[0](l) + lami[1] * fpts[1](l) + lami[2] * fpts[2](l) + lami[3] * fpts[3](l); curv.CalcElementTransformation (xl, ei, grid[ix][iy], dxdxi); Vec<3> gtaux = dxdxi * taux; Vec<3> gtauy = dxdxi * tauy; gridn[ix][iy] = Cross (gtauy, gtaux).Normalize(); } for (int ix = 0; ix < hoplotn; ix++) for (int iy = 0; iy < hoplotn; iy++) { glNormal3dv (gridn[ix][iy]); glVertex3dv (grid[ix][iy]); glNormal3dv (gridn[ix+1][iy]); glVertex3dv (grid[ix+1][iy]); glNormal3dv (gridn[ix+1][iy+1]); glVertex3dv (grid[ix+1][iy+1]); glNormal3dv (gridn[ix][iy+1]); glVertex3dv (grid[ix][iy+1]); } } glEnd (); */ const ELEMENT_FACE * faces = MeshTopology :: GetFaces1 (HEX); const Point3d * vertices = MeshTopology :: GetVertices (HEX); Point<3> grid[11][11]; Point<3> fpts[4]; int order = vispar.subdivisions+1; for (int quad = 0; quad<6; quad++) { for (int j = 0; j < 4; j++) fpts[j] = vertices[faces[quad][j]-1]; static Point<3> c(0.5, 0.5, 0.5); if (vispar.shrink < 1) for (int j = 0; j < 4; j++) fpts[j] += (1-vispar.shrink) * (c-fpts[j]); for (int ix = 0; ix <= order; ix++) for (int iy = 0; iy <= order; iy++) { double lami[4] = { (1-double(ix)/order) * (1-double(iy)/order), ( double(ix)/order) * (1-double(iy)/order), ( double(ix)/order) * ( double(iy)/order), (1-double(ix)/order) * ( double(iy)/order) }; Point<3> xl; for (int l = 0; l < 3; l++) xl(l) = lami[0] * fpts[0](l) + lami[1] * fpts[1](l) + lami[2] * fpts[2](l) + lami[3] * fpts[3](l); curv.CalcElementTransformation (xl, ei, grid[ix][iy]); } for (int j = 0; j <= order; j++) ToBernstein (order, &grid[j][0], &grid[0][1]-&grid[0][0]); for (int j = 0; j <= order; j++) ToBernstein (order, &grid[0][j], &grid[1][0]-&grid[0][0]); glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, &grid[0][1](0)-&grid[0][0](0), order+1, 0.0, 1.0, &grid[1][0](0)-&grid[0][0](0), order+1, &grid[0][0](0)); glEnable(GL_MAP2_VERTEX_3); glEnable(GL_AUTO_NORMAL); glMapGrid2f(8, 0.0, 1.0, 8, 0.0, 1.0); glEvalMesh2(GL_FILL, 0, 8, 0, 8); glDisable (GL_AUTO_NORMAL); glDisable (GL_MAP2_VERTEX_3); } } else { Point3d c(0,0,0); if (vispar.shrink < 1) { for (int j = 1; j <= 8; j++) { Point3d p = mesh->Point(el.PNum(j)); c.X() += p.X(); c.Y() += p.Y(); c.Z() += p.Z(); } c.X() /= 8; c.Y() /= 8; c.Z() /= 8; } glBegin (GL_TRIANGLES); el.GetSurfaceTriangles (faces); for (int j = 1; j <= faces.Size(); j++) { Element2d & face = faces.Elem(j); Point<3> lp1 = mesh->Point (el.PNum(face.PNum(1))); Point<3> lp2 = mesh->Point (el.PNum(face.PNum(2))); Point<3> lp3 = mesh->Point (el.PNum(face.PNum(3))); Vec<3> n = Cross (lp3-lp1, lp2-lp1); n.Normalize(); glNormal3dv (n); if (vispar.shrink < 1) { lp1 = c + vispar.shrink * (lp1 - c); lp2 = c + vispar.shrink * (lp2 - c); lp3 = c + vispar.shrink * (lp3 - c); } glVertex3dv (lp1); glVertex3dv (lp2); glVertex3dv (lp3); } glEnd(); } } } glEndList (); } void VisualSceneMesh :: BuildPyramidList() { if (pyramidtimestamp > mesh->GetTimeStamp () && pyramidtimestamp > vispar.clipplanetimestamp ) return; if (!lock) { lock = new NgLock (mesh->Mutex()); lock -> Lock(); } pyramidtimestamp = NextTimeStamp(); if (pyramidlist) glDeleteLists (pyramidlist, 1); pyramidlist = glGenLists (1); glNewList (pyramidlist, GL_COMPILE); static float pyramidcol[] = { 1.0f, 0.0f, 1.0f, 1.0f }; glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, pyramidcol); glLineWidth (1.0f); Array faces; for (ElementIndex ei = 0; ei < mesh->GetNE(); ei++) { const Element & el = (*mesh)[ei]; if (el.GetType() == PYRAMID && !el.IsDeleted()) { int i = ei + 1; CurvedElements & curv = mesh->GetCurvedElements(); if (curv.IsHighOrder()) // && curv.IsElementCurved(ei)) { const ELEMENT_FACE * faces = MeshTopology :: GetFaces1 (PYRAMID); const Point3d * vertices = MeshTopology :: GetVertices (PYRAMID); Point<3> grid[11][11]; Point<3> fpts[4]; int order = vispar.subdivisions+1; for (int trig = 0; trig < 4; trig++) { for (int j = 0; j < 3; j++) fpts[j] = vertices[faces[trig][j]-1]; static Point<3> c(0.375, 0.375, 0.25); if (vispar.shrink < 1) for (int j = 0; j < 3; j++) fpts[j] += (1-vispar.shrink) * (c-fpts[j]); for (int ix = 0; ix <= order; ix++) for (int iy = 0; iy <= order; iy++) { double lami[3] = { (1-double(ix)/order) * (1-double(iy)/order), ( double(ix)/order) * (1-double(iy)/order), double(iy)/order }; Point<3> xl; for (int l = 0; l < 3; l++) xl(l) = lami[0] * fpts[0](l) + lami[1] * fpts[1](l) + lami[2] * fpts[2](l); curv.CalcElementTransformation (xl, i-1, grid[ix][iy]); } for (int j = 0; j <= order; j++) ToBernstein (order, &grid[j][0], &grid[0][1]-&grid[0][0]); for (int j = 0; j <= order; j++) ToBernstein (order, &grid[0][j], &grid[1][0]-&grid[0][0]); glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, &grid[0][1](0)-&grid[0][0](0), order+1, 0.0, 1.0, &grid[1][0](0)-&grid[0][0](0), order+1, &grid[0][0](0)); glEnable(GL_MAP2_VERTEX_3); glEnable(GL_AUTO_NORMAL); glMapGrid2f(8, 0.0, 0.999f, 8, 0.0, 1.0); glEvalMesh2(GL_FILL, 0, 8, 0, 8); glDisable (GL_AUTO_NORMAL); glDisable (GL_MAP2_VERTEX_3); } for (int quad = 4; quad < 5; quad++) { for (int j = 0; j < 4; j++) fpts[j] = vertices[faces[quad][j]-1]; static Point<3> c(0.375, 0.375, 0.25); if (vispar.shrink < 1) for (int j = 0; j < 4; j++) fpts[j] += (1-vispar.shrink) * (c-fpts[j]); for (int ix = 0; ix <= order; ix++) for (int iy = 0; iy <= order; iy++) { double lami[4] = { (1-double(ix)/order) * (1-double(iy)/order), ( double(ix)/order) * (1-double(iy)/order), ( double(ix)/order) * ( double(iy)/order), (1-double(ix)/order) * ( double(iy)/order) }; Point<3> xl; for (int l = 0; l < 3; l++) xl(l) = lami[0] * fpts[0](l) + lami[1] * fpts[1](l) + lami[2] * fpts[2](l) + lami[3] * fpts[3](l); curv.CalcElementTransformation (xl, ei, grid[ix][iy]); } for (int j = 0; j <= order; j++) ToBernstein (order, &grid[j][0], &grid[0][1]-&grid[0][0]); for (int j = 0; j <= order; j++) ToBernstein (order, &grid[0][j], &grid[1][0]-&grid[0][0]); glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, &grid[0][1](0)-&grid[0][0](0), order+1, 0.0, 1.0, &grid[1][0](0)-&grid[0][0](0), order+1, &grid[0][0](0)); glEnable(GL_MAP2_VERTEX_3); glEnable(GL_AUTO_NORMAL); glMapGrid2f(8, 0.0, 1.0, 8, 0.0, 1.0); glEvalMesh2(GL_FILL, 0, 8, 0, 8); glDisable (GL_AUTO_NORMAL); glDisable (GL_MAP2_VERTEX_3); } /* int hoplotn = 1 << vispar.subdivisions; const ELEMENT_FACE * faces = MeshTopology :: GetFaces (PYRAMID); const Point3d * vertices = MeshTopology :: GetVertices (PYRAMID); Point<3> grid[33][33]; Vec<3> gridn[33][33]; glBegin (GL_TRIANGLES); for (int trig = 0; trig < 4; trig++) { Point<3> p0 = vertices[faces[trig][0]-1]; Point<3> p1 = vertices[faces[trig][1]-1]; Point<3> p2 = vertices[faces[trig][2]-1]; if (vispar.shrink < 1) { static Point<3> c(0.375, 0.375, 0.25); p0 = c + vispar.shrink * (p0 - c); p1 = c + vispar.shrink * (p1 - c); p2 = c + vispar.shrink * (p2 - c); } Vec<3> taux = p0-p2; Vec<3> tauy = p1-p2; Vec<3> gtaux, gtauy; Point<3> xl; Mat<3,3> dxdxi; for (int ix = 0; ix <= hoplotn; ix++) for (int iy = 0; iy <= hoplotn-ix; iy++) { for (int l = 0; l < 3; l++) xl(l) = (1-double(ix+iy)/hoplotn) * p2(l) + (double(ix)/hoplotn) * p0(l) + (double(iy)/hoplotn) * p1(l); curv.CalcElementTransformation (xl, i-1, grid[ix][iy], dxdxi); gtaux = dxdxi * taux; gtauy = dxdxi * tauy; gridn[ix][iy] = Cross (gtauy, gtaux).Normalize(); } for (int ix = 0; ix < hoplotn; ix++) for (int iy = 0; iy < hoplotn-ix; iy++) { glNormal3dv (gridn[ix][iy]); glVertex3dv (grid[ix][iy]); glNormal3dv (gridn[ix+1][iy]); glVertex3dv (grid[ix+1][iy]); glNormal3dv (gridn[ix][iy+1]); glVertex3dv (grid[ix][iy+1]); if (iy < hoplotn-ix-1) { glNormal3dv (gridn[ix][iy+1]); glVertex3dv (grid[ix][iy+1]); glNormal3dv (gridn[ix+1][iy]); glVertex3dv (grid[ix+1][iy]); glNormal3dv (gridn[ix+1][iy+1]); glVertex3dv (grid[ix+1][iy+1]); } } } glEnd (); glBegin (GL_QUADS); for (int quad = 4; quad < 5; quad++) { Point<3> p0 = vertices[faces[quad][0]-1]; Point<3> p1 = vertices[faces[quad][1]-1]; Point<3> p2 = vertices[faces[quad][2]-1]; Point<3> p3 = vertices[faces[quad][3]-1]; if (vispar.shrink < 1) { static Point<3> c(0.375, 0.375, 0.25); p0 = c + vispar.shrink * (p0 - c); p1 = c + vispar.shrink * (p1 - c); p2 = c + vispar.shrink * (p2 - c); p3 = c + vispar.shrink * (p3 - c); } Vec<3> taux = p1-p0; Vec<3> tauy = p3-p0; Vec<3> gtaux, gtauy; Point<3> xl, xg; Mat<3,3> dxdxi; for (int ix = 0; ix <= hoplotn; ix++) for (int iy = 0; iy <= hoplotn; iy++) { Point<3> xl; for (int l = 0; l < 3; l++) xl(l) = (1-double(ix)/hoplotn)*(1-double(iy)/hoplotn) * p0(l) + ( double(ix)/hoplotn)*(1-double(iy)/hoplotn) * p1(l) + ( double(ix)/hoplotn)*( double(iy)/hoplotn) * p2(l) + (1-double(ix)/hoplotn)*( double(iy)/hoplotn) * p3(l); curv.CalcElementTransformation (xl, i-1, grid[ix][iy], dxdxi); gtaux = dxdxi * taux; gtauy = dxdxi * tauy; gridn[ix][iy] = Cross (gtauy, gtaux).Normalize(); } for (int ix = 0; ix < hoplotn; ix++) for (int iy = 0; iy < hoplotn; iy++) { glNormal3dv (gridn[ix][iy]); glVertex3dv (grid[ix][iy]); glNormal3dv (gridn[ix+1][iy]); glVertex3dv (grid[ix+1][iy]); glNormal3dv (gridn[ix+1][iy+1]); glVertex3dv (grid[ix+1][iy+1]); glNormal3dv (gridn[ix][iy+1]); glVertex3dv (grid[ix][iy+1]); } } glEnd (); */ } else { Point3d c(0,0,0); if (vispar.shrink < 1) { for (int j = 1; j <= 5; j++) { Point3d p = mesh->Point(el.PNum(j)); c.X() += p.X() / 5; c.Y() += p.Y() / 5; c.Z() += p.Z() / 5; } } el.GetSurfaceTriangles (faces); if (el.PNum(1)) { glBegin (GL_TRIANGLES); for (int j = 1; j <= faces.Size(); j++) { Element2d & face = faces.Elem(j); Point3d lp1 = mesh->Point (el.PNum(face.PNum(1))); Point3d lp2 = mesh->Point (el.PNum(face.PNum(2))); Point3d lp3 = mesh->Point (el.PNum(face.PNum(3))); Vec3d n = Cross (Vec3d (lp1, lp2), Vec3d (lp1, lp3)); n /= (n.Length()+1e-12); n *= -1; glNormal3d (n.X(), n.Y(), n.Z()); if (vispar.shrink < 1) { lp1 = c + vispar.shrink * (lp1 - c); lp2 = c + vispar.shrink * (lp2 - c); lp3 = c + vispar.shrink * (lp3 - c); } glVertex3d (lp1.X(), lp1.Y(), lp1.Z()); glVertex3d (lp2.X(), lp2.Y(), lp2.Z()); glVertex3d (lp3.X(), lp3.Y(), lp3.Z()); } glEnd(); } } } } glEndList (); } void VisualSceneMesh :: BuildBadelList() { ; } void VisualSceneMesh :: BuildIdentifiedList() { ; } void VisualSceneMesh :: BuildDomainSurfList() { if (domainsurflist) glDeleteLists (domainsurflist, 1); domainsurflist = glGenLists (1); glNewList (domainsurflist, GL_COMPILE); int i, j; glLineWidth (1.0f); glDisable (GL_COLOR_MATERIAL); for (i = 1; i <= mesh->GetNSE(); i++) { Element2d el = mesh->SurfaceElement (i); int drawel = 1; for (j = 1; j <= el.GetNP(); j++) { if (!el.PNum(j)) drawel = 0; } if (!drawel) continue; if (el.GetIndex() < 1 || el.GetIndex() > mesh->GetNFD()) continue; int domin = mesh->GetFaceDescriptor(el.GetIndex()).DomainIn(); int domout = mesh->GetFaceDescriptor(el.GetIndex()).DomainOut(); int fac; if (domin == vispar.drawdomainsurf) fac = 1; else if (domout == vispar.drawdomainsurf) fac = -1; else continue; GLfloat matcol[] = { 1, 0, 0, 1 }; glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, matcol); if (el.GetNP() == 3) { glBegin (GL_TRIANGLES); const Point3d & lp1 = mesh->Point (el.PNum(1)); const Point3d & lp2 = mesh->Point (el.PNum(2)); const Point3d & lp3 = mesh->Point (el.PNum(3)); Vec3d n = Cross (Vec3d (lp1, lp2), Vec3d (lp1, lp3)); n /= ( fac * (n.Length()+1e-12)); glNormal3d (n.X(), n.Y(), n.Z()); if (!vispar.colormeshsize) { glVertex3d (lp1.X(), lp1.Y(), lp1.Z()); glVertex3d (lp2.X(), lp2.Y(), lp2.Z()); glVertex3d (lp3.X(), lp3.Y(), lp3.Z()); } glEnd(); } else if (el.GetNP() == 4) { glBegin (GL_QUADS); const Point3d & lp1 = mesh->Point (el.PNum(1)); const Point3d & lp2 = mesh->Point (el.PNum(2)); const Point3d & lp3 = mesh->Point (el.PNum(4)); const Point3d & lp4 = mesh->Point (el.PNum(3)); Vec3d n = Cross (Vec3d (lp1, lp2), Vec3d (lp1, Center (lp3, lp4))); n /= (fac * (n.Length()+1e-12)); glNormal3d (n.X(), n.Y(), n.Z()); glVertex3d (lp1.X(), lp1.Y(), lp1.Z()); glVertex3d (lp2.X(), lp2.Y(), lp2.Z()); glVertex3d (lp4.X(), lp4.Y(), lp4.Z()); glVertex3d (lp3.X(), lp3.Y(), lp3.Z()); glEnd(); } else if (el.GetNP() == 6) { glBegin (GL_TRIANGLES); static int trigs[4][3] = { { 1, 6, 5 }, { 2, 4, 6 }, { 3, 5, 4 }, { 4, 5, 6 } }; for (j = 0; j < 4; j++) { const Point3d & lp1 = mesh->Point (el.PNum(trigs[j][0])); const Point3d & lp2 = mesh->Point (el.PNum(trigs[j][1])); const Point3d & lp3 = mesh->Point (el.PNum(trigs[j][2])); Vec3d n = Cross (Vec3d (lp1, lp2), Vec3d (lp1, lp3)); n /= (fac * (n.Length() + 1e-12)); glNormal3d (n.X(), n.Y(), n.Z()); glVertex3d (lp1.X(), lp1.Y(), lp1.Z()); glVertex3d (lp2.X(), lp2.Y(), lp2.Z()); glVertex3d (lp3.X(), lp3.Y(), lp3.Z()); } glEnd(); } } glEndList (); } void VisualSceneMesh :: MouseDblClick (int px, int py) { if(lock) { lock->UnLock(); delete lock; lock = NULL; } MouseDblClickSelect(px,py,clipplane,backcolor,transformationmat,center,rad, filledlist,selelement,selface,seledge,selpoint,selpoint2,locpi); selecttimestamp = NextTimeStamp(); /* int i, hits; // select surface triangle by mouse click GLuint selbuf[10000]; glSelectBuffer (10000, selbuf); glRenderMode (GL_SELECT); GLint viewport[4]; glGetIntegerv (GL_VIEWPORT, viewport); glMatrixMode (GL_PROJECTION); glPushMatrix(); GLdouble projmat[16]; glGetDoublev (GL_PROJECTION_MATRIX, projmat); glLoadIdentity(); gluPickMatrix (px, viewport[3] - py, 1, 1, viewport); glMultMatrixd (projmat); glClearColor(backcolor, backcolor, backcolor, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode (GL_MODELVIEW); glPushMatrix(); glMultMatrixf (transformationmat); // SetClippingPlane(); glInitNames(); glPushName (1); glPolygonOffset (1, 1); glEnable (GL_POLYGON_OFFSET_FILL); glDisable(GL_CLIP_PLANE0); if (vispar.clipenable) { Vec<3> n(clipplane[0], clipplane[1], clipplane[2]); double len = Abs(n); double mu = -clipplane[3] / (len*len); Point<3> p (mu * n); n /= len; Vec<3> t1 = n.GetNormal (); Vec<3> t2 = Cross (n, t1); double xi1mid = (center - p) * t1; double xi2mid = (center - p) * t2; glLoadName (0); glBegin (GL_QUADS); glVertex3dv (p + (xi1mid-rad) * t1 + (xi2mid-rad) * t2); glVertex3dv (p + (xi1mid+rad) * t1 + (xi2mid-rad) * t2); glVertex3dv (p + (xi1mid+rad) * t1 + (xi2mid+rad) * t2); glVertex3dv (p + (xi1mid-rad) * t1 + (xi2mid+rad) * t2); glEnd (); } // SetClippingPlane(); glCallList (filledlist); glDisable (GL_POLYGON_OFFSET_FILL); glPopName(); glMatrixMode (GL_PROJECTION); glPopMatrix(); glMatrixMode (GL_MODELVIEW); glPopMatrix(); glFlush(); hits = glRenderMode (GL_RENDER); // cout << "hits = " << hits << endl; int minname = 0; GLuint mindepth = 0; // find clippingplane GLuint clipdepth = 0; // GLuint(-1); for (i = 0; i < hits; i++) { int curname = selbuf[4*i+3]; if (!curname) clipdepth = selbuf[4*i+1]; } for (i = 0; i < hits; i++) { int curname = selbuf[4*i+3]; GLuint curdepth = selbuf[4*i+1]; if (curname && (curdepth > clipdepth) && (curdepth < mindepth || !minname)) { mindepth = curdepth; minname = curname; } } seledge = -1; if (minname) { const Element2d & sel = mesh->SurfaceElement(minname); cout << "select element " << minname << " on face " << sel.GetIndex() << endl; cout << "Nodes: "; for (i = 1; i <= sel.GetNP(); i++) cout << sel.PNum(i) << " "; cout << endl; selelement = minname; selface = mesh->SurfaceElement(minname).GetIndex(); locpi = (locpi % sel.GetNP()) + 1; selpoint2 = selpoint; selpoint = sel.PNum(locpi); cout << "selected point " << selpoint << ", pos = " << mesh->Point (selpoint) << endl; for (i = 1; i <= mesh->GetNSeg(); i++) { const Segment & seg = mesh->LineSegment(i); if (seg[0] == selpoint && seg[1] == selpoint2 || seg[1] == selpoint && seg[0] == selpoint2) { seledge = seg.edgenr; cout << "seledge = " << seledge << endl; } } } else { selface = -1; selelement = -1; selpoint = -1; selpoint2 = -1; } glDisable(GL_CLIP_PLANE0); selecttimestamp = NextTimeStamp(); */ } void MouseDblClickSelect (const int px, const int py, const GLdouble * clipplane, const GLdouble backcolor, const float * transformationmat, const Point3d & center, const double rad, const int displaylist, int & selelement, int & selface, int & seledge, int & selpoint, int & selpoint2, int & locpi) { int i, hits; // select surface triangle by mouse click GLuint selbuf[10000]; glSelectBuffer (10000, selbuf); glRenderMode (GL_SELECT); GLint viewport[4]; glGetIntegerv (GL_VIEWPORT, viewport); glMatrixMode (GL_PROJECTION); glPushMatrix(); GLdouble projmat[16]; glGetDoublev (GL_PROJECTION_MATRIX, projmat); glLoadIdentity(); gluPickMatrix (px, viewport[3] - py, 1, 1, viewport); glMultMatrixd (projmat); glClearColor(backcolor, backcolor, backcolor, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode (GL_MODELVIEW); glPushMatrix(); glMultMatrixf (transformationmat); // SetClippingPlane(); glInitNames(); glPushName (1); glPolygonOffset (1, 1); glEnable (GL_POLYGON_OFFSET_FILL); glDisable(GL_CLIP_PLANE0); if (vispar.clipenable) { Vec<3> n(clipplane[0], clipplane[1], clipplane[2]); double len = Abs(n); double mu = -clipplane[3] / (len*len); Point<3> p (mu * n); n /= len; Vec<3> t1 = n.GetNormal (); Vec<3> t2 = Cross (n, t1); double xi1mid = (center - p) * t1; double xi2mid = (center - p) * t2; glLoadName (0); glBegin (GL_QUADS); glVertex3dv (p + (xi1mid-rad) * t1 + (xi2mid-rad) * t2); glVertex3dv (p + (xi1mid+rad) * t1 + (xi2mid-rad) * t2); glVertex3dv (p + (xi1mid+rad) * t1 + (xi2mid+rad) * t2); glVertex3dv (p + (xi1mid-rad) * t1 + (xi2mid+rad) * t2); glEnd (); } // SetClippingPlane(); glCallList (displaylist); glDisable (GL_POLYGON_OFFSET_FILL); glPopName(); glMatrixMode (GL_PROJECTION); glPopMatrix(); glMatrixMode (GL_MODELVIEW); glPopMatrix(); glFlush(); hits = glRenderMode (GL_RENDER); //cout << "hits = " << hits << endl; int minname = 0; GLuint mindepth = 0; // find clippingplane GLuint clipdepth = 0; // GLuint(-1); for (i = 0; i < hits; i++) { int curname = selbuf[4*i+3]; if (!curname) clipdepth = selbuf[4*i+1]; } for (i = 0; i < hits; i++) { int curname = selbuf[4*i+3]; GLuint curdepth = selbuf[4*i+1]; /* cout << selbuf[4*i] << " " << selbuf[4*i+1] << " " << selbuf[4*i+2] << " " << selbuf[4*i+3] << endl; */ if (curname && (curdepth > clipdepth) && (curdepth < mindepth || !minname)) { mindepth = curdepth; minname = curname; } } seledge = -1; if (minname) { const Element2d & sel = mesh->SurfaceElement(minname); cout << "select element " << minname << " on face " << sel.GetIndex() << endl; cout << "Nodes: "; for (i = 1; i <= sel.GetNP(); i++) cout << sel.PNum(i) << " "; cout << endl; selelement = minname; selface = mesh->SurfaceElement(minname).GetIndex(); locpi = (locpi % sel.GetNP()) + 1; selpoint2 = selpoint; selpoint = sel.PNum(locpi); cout << "selected point " << selpoint << ", pos = " << mesh->Point (selpoint) << endl; for (i = 1; i <= mesh->GetNSeg(); i++) { const Segment & seg = mesh->LineSegment(i); if ( (seg[0] == selpoint && seg[1] == selpoint2) || (seg[1] == selpoint && seg[0] == selpoint2) ) { seledge = seg.edgenr; cout << "seledge = " << seledge << endl; } } } else { selface = -1; selelement = -1; selpoint = -1; selpoint2 = -1; } glDisable(GL_CLIP_PLANE0); #ifdef PARALLELGL vsmesh.Broadcast (); #endif } void VisualSceneMesh :: SetSelectedFace (int asf) { selface = asf; selecttimestamp = GetTimeStamp(); } } #endif // NOTCL netgen-4.9.13/libsrc/visualization/vsfieldlines.cpp0000644000175000001440000004233611240003502017352 00000000000000#ifndef NOTCL #include #include "incvis.hpp" #include #include #include #include #include namespace netgen { extern AutoPtr mesh; RKStepper :: ~RKStepper() { delete a; } RKStepper :: RKStepper(int type) : a(NULL), tolerance(1e100) { notrestarted = 0; if (type == 0) // explicit Euler { c.SetSize(1); c[0] = 0; b.SetSize(1); b[0] = 1; steps = order = 1; } else if (type == 1) // Euler-Cauchy { c.SetSize(2); c[0] = 0; c[1] = 0.5; b.SetSize(2); b[0] = 0; b[1] = 1; Array size(2); size[0] = 0; size[1] = 1; a = new TABLE(size); a->Set(2,1,0.5); // Set, Get: 1-based! steps = order = 2; } else if (type == 2) // Simpson { c.SetSize(3); c[0] = 0; c[1] = 1; c[2] = 0.5; b.SetSize(3); b[0] = b[1] = 1./6.; b[2] = 2./3.; Array size(3); size[0] = 0; size[1] = 1; size[2] = 2; a = new TABLE(size); a->Set(2,1,1); a->Set(3,1,0.25); a->Set(3,2,0.25); steps = order = 3; } else if (type == 3) // classical Runge-Kutta { c.SetSize(4); c[0] = 0; c[1] = c[2] = 0.5; c[3] = 1; b.SetSize(4); b[0] = b[3] = 1./6.; b[1] = b[2] = 1./3.; Array size(4); size[0] = 0; size[1] = 1; size[2] = 2; size[3] = 3; a = new TABLE(size); a->Set(2,1,0.5); a->Set(3,1,0); a->Set(3,2,0.5); a->Set(4,1,0); a->Set(4,2,0); a->Set(4,3,1); steps = order = 4; } K.SetSize(steps); } void RKStepper :: StartNextValCalc(const Point3d & astartval, const double astartt, const double ah, const bool aadaptive) { //cout << "Starting RK-Step with h=" << ah << endl; stepcount = 0; h = ah; startt = astartt; startval = astartval; adaptive = aadaptive; adrun = 0; } bool RKStepper :: GetNextData(Point3d & val, double & t, double & ah) { bool finished(false); //cout << "stepcount " << stepcount << endl; if(stepcount <= steps) { t = startt + c[stepcount-1]*h; val = startval; for(int i=0; iGet(stepcount,i+1) * K[i]; } if(stepcount == steps) { val = startval; for(int i=0; i 1.3) fac = 1.3; if(fac < 1 || notrestarted >= 2) ah = 2.*h * fac; if(err < tolerance) { finished = true; notrestarted++; //(*testout) << "finished RK-Step, new h=" << ah << " tolerance " << tolerance << " err " << err << endl; } else { //ah *= 0.9; notrestarted = 0; //(*testout) << "restarting h " << 2.*h << " ah " << ah << " tolerance " << tolerance << " err " << err << endl; StartNextValCalc(startval_bak,startt_bak, ah, adaptive); } } } else { t = startt + h; finished = true; } } if(stepcount == 0) { t = startt + c[stepcount]*h; val = startval; for(int i=0; iGet(stepcount,i) * K[i]; } return finished; } bool RKStepper :: FeedNextF(const Vec3d & f) { K[stepcount] = f; stepcount++; return true; } void FieldLineCalc :: GenerateFieldLines(Array & potential_startpoints, const int numlines, const int gllist, const double minval, const double maxval, const int logscale, double phaser, double phasei) { Array points; Array values; Array drawelems; Array dirstart; if(vsol -> iscomplex) SetPhase(phaser,phasei); double crit = 1.0; if(randomized) { double sum = 0; double lami[3]; double values[6]; Vec3d v; for(int i=0; iiscomplex, phaser, phasei); sum += v.Length(); } crit = sum/double(numlines); } int calculated = 0; cout << endl; for(int i=0; i= numlines) break; Calc(potential_startpoints[i],points,values,drawelems,dirstart); bool usable = false; for(int j=1; j 0) ? rel_length : 0.5; maxlength *= 2.*rad; thickness = (rel_thickness > 0) ? rel_thickness : 0.0015; thickness *= 2.*rad; double auxtolerance = (rel_tolerance > 0) ? rel_tolerance : 1.5e-3; auxtolerance *= 2.*rad; stepper.SetTolerance(auxtolerance); direction = adirection; maxpoints = amaxpoints; if(direction == 0) { maxlength *= 0.5; maxpoints /= 2; } phaser = 1; phasei = 0; critical_value = -1; randomized = false; } void FieldLineCalc :: Calc(const Point3d & startpoint, Array & points, Array & vals, Array & drawelems, Array & dirstart) { double lami[3], startlami[3]; double values[6]; double dummyt(0); Vec3d v; Vec3d startv; Point3d newp; double h; double startval; bool startdraw; bool drawelem = false; int elnr; for (int i=0; i<6; i++) values[i]=0.0; for (int i=0; i<3; i++) lami[i]=0.0; for (int i=0; i<3; i++) startlami[i]=0.0; points.SetSize(0); vals.SetSize(0); drawelems.SetSize(0); dirstart.SetSize(0); dirstart.Append(0); int startelnr = mesh.GetElementOfPoint(startpoint,startlami,true) - 1; (*testout) << "p = " << startpoint << "; elnr = " << startelnr << endl; if (startelnr == -1) return; mesh.SetPointSearchStartElement(startelnr); if (mesh.GetDimension()==3) startdraw = vss.GetValues ( vsol, startelnr, startlami[0], startlami[1], startlami[2], values); else startdraw = vss.GetSurfValues ( vsol, startelnr, startlami[0], startlami[1], values); VisualSceneSolution::RealVec3d ( values, startv, vsol->iscomplex, phaser, phasei); startval = startv.Length(); if(critical_value > 0 && fabs(startval) < critical_value) return; //cout << "p = " << startpoint << "; elnr = " << startelnr << endl; for(int dir = 1; dir >= -1; dir -= 2) { if(dir*direction < 0) continue; points.Append(startpoint); vals.Append(startval); drawelems.Append(startdraw); h = 0.001*rad/startval; // otherwise no nice lines; should be made accessible from outside v = startv; if(dir == -1) v *= -1.; elnr = startelnr; lami[0] = startlami[0]; lami[1] = startlami[1]; lami[2] = startlami[2]; for(double length = 0; length < maxlength; length += h*vals.Last()) { if(v.Length() < 1e-12*rad) { (*testout) << "Current fieldlinecalculation came to a stillstand at " << points.Last() << endl; break; } stepper.StartNextValCalc(points.Last(),dummyt,h,true); stepper.FeedNextF(v); while(!stepper.GetNextData(newp,dummyt,h) && elnr != -1) { elnr = mesh.GetElementOfPoint(newp,lami,true) - 1; if(elnr != -1) { mesh.SetPointSearchStartElement(elnr); if (mesh.GetDimension()==3) drawelem = vss.GetValues (vsol, elnr, lami[0], lami[1], lami[2], values); else drawelem = vss.GetSurfValues (vsol, elnr, lami[0], lami[1], values); VisualSceneSolution::RealVec3d (values, v, vsol->iscomplex, phaser, phasei); if(dir == -1) v *= -1.; stepper.FeedNextF(v); } } if (elnr == -1) { //cout << "direction " < 1) (*testout) << "Points in current fieldline: " << points.Size() << ", current position: " << newp << endl; if(maxpoints > 0 && points.Size() >= maxpoints) { break; } //cout << "length " << length << " h " << h << " vals.Last() " << vals.Last() << " maxlength " << maxlength << endl; } dirstart.Append(points.Size()); } } void VisualSceneSolution :: BuildFieldLinesFromBox(Array & startpoints) { if(fieldlines_startarea_parameter[0] > fieldlines_startarea_parameter[3] || fieldlines_startarea_parameter[1] > fieldlines_startarea_parameter[4] || fieldlines_startarea_parameter[2] > fieldlines_startarea_parameter[5]) { Point3d pmin, pmax; mesh->GetBox (pmin, pmax); fieldlines_startarea_parameter[0] = pmin.X(); fieldlines_startarea_parameter[1] = pmin.Y(); fieldlines_startarea_parameter[2] = pmin.Z(); fieldlines_startarea_parameter[3] = pmax.X(); fieldlines_startarea_parameter[4] = pmax.Y(); fieldlines_startarea_parameter[5] = pmax.Z(); } for (int i = 1; i <= startpoints.Size(); i++) { Point3d p (fieldlines_startarea_parameter[0] + double (rand()) / RAND_MAX * (fieldlines_startarea_parameter[3]-fieldlines_startarea_parameter[0]), fieldlines_startarea_parameter[1] + double (rand()) / RAND_MAX * (fieldlines_startarea_parameter[4]-fieldlines_startarea_parameter[1]), fieldlines_startarea_parameter[2] + double (rand()) / RAND_MAX * (fieldlines_startarea_parameter[5]-fieldlines_startarea_parameter[2])); startpoints[i-1] = p; } } void VisualSceneSolution :: BuildFieldLinesFromLine(Array & startpoints) { for (int i = 1; i <= startpoints.Size(); i++) { double s = double (rand()) / RAND_MAX; Point3d p (fieldlines_startarea_parameter[0] + s * (fieldlines_startarea_parameter[3]-fieldlines_startarea_parameter[0]), fieldlines_startarea_parameter[1] + s * (fieldlines_startarea_parameter[4]-fieldlines_startarea_parameter[1]), fieldlines_startarea_parameter[2] + s * (fieldlines_startarea_parameter[5]-fieldlines_startarea_parameter[2])); startpoints[i-1] = p; } } void VisualSceneSolution :: BuildFieldLinesFromFile(Array & startpoints) { ifstream * infile; infile = new ifstream(fieldlines_filename.c_str()); //cout << "reading from file " << fieldlines_filename << endl; int numpoints = 0; string keyword; double dparam; int iparam; while(infile->good()) { (*infile) >> keyword; if(keyword == "point") numpoints++; else if(keyword == "line" || keyword == "box") { for(int i=0; i<6; i++) (*infile) >> dparam; (*infile) >> iparam; numpoints += iparam; } } delete infile; //cout << numpoints << " startpoints" << endl; startpoints.SetSize(numpoints); infile = new ifstream(fieldlines_filename.c_str()); numpoints = 0; while(infile->good()) { (*infile) >> keyword; if (keyword == "point") { (*infile) >> startpoints[numpoints].X(); (*infile) >> startpoints[numpoints].Y(); (*infile) >> startpoints[numpoints].Z(); numpoints++; } else if (keyword == "line" || keyword == "box") { for(int i=0; i<6; i++) (*infile) >> fieldlines_startarea_parameter[i]; (*infile) >> iparam; Array auxpoints(iparam); if (keyword == "box") BuildFieldLinesFromBox(auxpoints); else if (keyword == "line") BuildFieldLinesFromLine(auxpoints); for(int i=0; i & startpoints) { Array elements_2d; //cout << "fieldlines_startface " << fieldlines_startface << endl; mesh->GetSurfaceElementsOfFace(fieldlines_startface,elements_2d); if(elements_2d.Size() == 0) { cerr << "No Elements on selected face (?)" << endl; return; } Vec3d v1,v2,cross; double area = 0; int i; for(i=0; iSurfaceElement(elements_2d[i]); v1 = mesh->Point(elem[1]) - mesh->Point(elem[0]); v2 = mesh->Point(elem[2]) - mesh->Point(elem[0]); cross = Cross(v1,v2); area += cross.Length(); if(elem.GetNV() == 4) { v1 = mesh->Point(elem[2]) - mesh->Point(elem[0]); v2 = mesh->Point(elem[3]) - mesh->Point(elem[0]); cross = Cross(v1,v2); area += cross.Length(); } } int startpointsp = 0; i = 0; while(startpointsp < startpoints.Size()) { const Element2d & elem = mesh->SurfaceElement(elements_2d[i]); int numtri = (elem.GetNV() == 3) ? 1 : 2; for(int tri = 0; startpointsp < startpoints.Size() && triPoint(elem[1]) - mesh->Point(elem[0]); v2 = mesh->Point(elem[2]) - mesh->Point(elem[0]); cross = Cross(v1,v2); } else if(tri == 1) { v1 = mesh->Point(elem[2]) - mesh->Point(elem[0]); v2 = mesh->Point(elem[3]) - mesh->Point(elem[0]); cross = Cross(v1,v2); } double thisarea = cross.Length(); int numloc = int(startpoints.Size()*thisarea/area); if(double (rand()) / RAND_MAX < startpoints.Size()*thisarea/area - numloc) numloc++; for(int j=0; startpointsp < startpoints.Size() && j 1) { s = 1.-s; t = 1.-t; } startpoints[startpointsp] = mesh->Point(elem[0]) + s*v1 +t*v2; startpointsp++; } } i++; if(i == elements_2d.Size()) i = 0; } } void VisualSceneSolution :: BuildFieldLinesPlot () { if (fieldlinestimestamp >= solutiontimestamp) return; fieldlinestimestamp = solutiontimestamp; if (fieldlineslist) glDeleteLists (fieldlineslist, num_fieldlineslists); if (vecfunction == -1) return; const SolData * vsol = soldata[fieldlines_vecfunction]; num_fieldlineslists = (vsol -> iscomplex && !fieldlines_fixedphase) ? 100 : 1; FieldLineCalc linecalc(*mesh,*this,vsol, fieldlines_rellength,fieldlines_maxpoints,fieldlines_relthickness,fieldlines_reltolerance,fieldlines_rktype); if(fieldlines_randomstart) linecalc.Randomized(); fieldlineslist = glGenLists (num_fieldlineslists); int num_startpoints = num_fieldlines / num_fieldlineslists; if (num_fieldlines % num_fieldlineslists != 0) num_startpoints++; if(fieldlines_randomstart) num_startpoints *= 10; Array startpoints(num_startpoints); for (int ln = 0; ln < num_fieldlineslists; ln++) { if(fieldlines_startarea == 0) BuildFieldLinesFromBox(startpoints); else if(fieldlines_startarea == 1) BuildFieldLinesFromFile(startpoints); else if(fieldlines_startarea == 2) BuildFieldLinesFromFace(startpoints); double phi; if(vsol -> iscomplex) { if(fieldlines_fixedphase) phi = fieldlines_phase; else phi = 2*M_PI*ln / num_fieldlineslists; } else phi = 0; cout << "phi = " << phi << endl; double phaser = cos(phi), phasei = sin(phi); glNewList(fieldlineslist+ln, GL_COMPILE); SetTextureMode (usetexture); linecalc.GenerateFieldLines(startpoints,num_fieldlines / num_fieldlineslists+1, fieldlineslist+ln,minval,maxval,logscale,phaser,phasei); glEndList (); } } } #endif // NOTCL netgen-4.9.13/libsrc/visualization/stlmeshing.cpp0000644000175000001440000006650311240003502017042 00000000000000#include #include #include #include #include #ifndef NOTCL #include #endif namespace netgen { /* //mmm #include "stlgeom/modeller.hpp" */ /* *********************** Draw STL Geometry **************** */ extern STLGeometry * stlgeometry; extern AutoPtr mesh; #ifdef OPENGL // #include "../../ngtcltk/mvdraw.hpp" VisualSceneSTLMeshing :: VisualSceneSTLMeshing () : VisualScene() { selecttrig = 0; nodeofseltrig = 1; stlgeometry->SetSelectTrig(selecttrig); stlgeometry->SetNodeOfSelTrig(nodeofseltrig); } VisualSceneSTLMeshing :: ~VisualSceneSTLMeshing () { ; } void VisualSceneSTLMeshing :: DrawScene () { int i, j, k; if (changeval != stlgeometry->GetNT()) BuildScene(); changeval = stlgeometry->GetNT(); int colormeshsize = vispar.colormeshsize; double hmin = 0.0, hmax = 1.0; if (colormeshsize) { hmax = -1E50; hmin = +1E50; double ms; for (i = 1; i <= stlgeometry->GetNP(); i++) { ms = mesh->GetH (stlgeometry->GetPoint(i)); hmin = min2(hmin,ms); hmax = max2(hmax,ms); } //hmax = mparam.maxh; //hmin = mesh->GetMinH (stlgeometry->GetBoundingBox().PMin(), // stlgeometry->GetBoundingBox().PMax()); if (hmin == 0) hmin = 0.1 * hmax; //hmax *= 1.1; } glClearColor(backcolor, backcolor, backcolor, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); SetLight(); glPushMatrix(); glMultMatrixf (transformationmat); SetClippingPlane (); glShadeModel (GL_SMOOTH); glDisable (GL_COLOR_MATERIAL); glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); float mat_spec_col[] = { 1, 1, 1, 1 }; glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, mat_spec_col); double shine = vispar.shininess; // double transp = vispar.transp; glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, shine); glLogicOp (GL_COPY); float mat_colred[] = { 0.9f, 0.0f, 0.0f, 1.0f }; float mat_colgreen[] = { 0.0f, 0.9f, 0.0f, 1.0f }; float mat_colblue[] = { 0.1f, 0.1f, 1.0f, 1.0f }; float mat_colbluegreen[] = { 0.1f, 0.5f, 0.9f, 1.0f }; // float mat_colpink[] = { 1.0f, 0.1f, 0.5f, 1.0f }; float mat_colviolet[] = { 1.0f, 0.1f, 1.0f, 1.0f }; float mat_colbrown[] = { 0.8f, 0.6f, 0.1f, 1.0f }; // float mat_colorange[] = { 0.9f, 0.7f, 0.1f, 1.0f }; // float mat_colturquis[] = { 0.0f, 1.0f, 0.8f, 1.0f }; float mat_colgrey[] = { 0.3f, 0.3f, 0.3f, 1.0f }; float mat_collred[] = { 1.0f, 0.5f, 0.5f, 1.0f }; float mat_collgreen[] = { 0.2f, 1.9f, 0.2f, 1.0f }; float mat_collbrown[] = { 1.0f, 0.8f, 0.3f, 1.0f }; float mat_collgrey[] = { 0.8f, 0.8f, 0.8f, 1.0f }; // float mat_colmgrey[] = { 0.4f, 0.4f, 0.4f, 1.0f }; float mat_colstlbody[] = { 0.0f, 0.0f, 0.8f, 1.0f }; float mat_colseltrig[] = { 0.7f, 0.7f, 0.3f, 1.0f }; float mat_colseledge[] = { 0.7f, 0.7f, 1.0f, 1.0f }; glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colblue); float pgoff = 0.5f; glPolygonOffset (pgoff*1, pgoff*1); glEnable (GL_POLYGON_OFFSET_FILL); glEnable (GL_NORMALIZE); /* { //mmm //test modeller Modeller model; //MoZylinder z1(Point3d(0,0,0),Vec3d(100,0,0),20,0.01); //model.Add(&z1); //MoZylinder z2(Point3d(50,50,0),Vec3d(0,-100,0),20,0.01); //model.Add(&z2); MoZylinder z1(Point3d(0,0,0),Vec3d(100,0,0),20,0.01); MoZylinder z2(Point3d(50,50,0),Vec3d(0,-100,0),20,0.01); MoCombine cb1(&z1,&z2); model.Add(&cb1); Array trigs; model.GetTriangles(trigs); int i, k; glBegin (GL_TRIANGLES); for (i = 1; i <= trigs.Size(); i++) { const MoTriangle & tria = trigs.Get(i); glNormal3f (tria.normal.X(), tria.normal.Y(), tria.normal.Z()); for (k = 0; k < 3; k++) { glVertex3f (tria.pts[k].X(), tria.pts[k].Y(), tria.pts[k].Z()); } } glEnd (); } */ if (!stlgeometry->trigsconverted) { glBegin (GL_TRIANGLES); for (j = 1; j <= stlgeometry -> GetNT(); j++) { /* if (j % 10 == seltria) glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colred); */ const Vec3d & n = stlgeometry->GetTriangle(j).Normal(); glNormal3f (n.X(), n.Y(), n.Z()); /* const STLReadTriangle & tria = stlgeometry -> GetReadTriangle(j); glNormal3f (tria.normal.X(), tria.normal.Y(), tria.normal.Z()); */ for (k = 1; k <= 3; k++) { const Point3d & tp = stlgeometry->GetPoint(stlgeometry->GetTriangle(j).PNum(k)); glVertex3f (tp.X(), tp.Y(), tp.Z()); } /* if (j%10 == seltria) glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colblue); */ } glEnd (); glDisable (GL_POLYGON_OFFSET_FILL); int showtrias = vispar.stlshowtrias; if (showtrias) { float mat_coll[] = { 0.2f, 0.2f, 0.2f, 1.f }; glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_coll); glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); glEnable (GL_NORMALIZE); glBegin (GL_TRIANGLES); for (j = 1; j <= stlgeometry -> GetNT(); j++) { const Vec3d & n = stlgeometry->GetTriangle(j).Normal(); glNormal3f (n.X(), n.Y(), n.Z()); /* const STLReadTriangle & tria = stlgeometry -> GetReadTriangle(j); glNormal3f (tria.normal.X(), tria.normal.Y(), tria.normal.Z()); */ for (k = 1; k <= 3; k++) { const Point3d & tp = stlgeometry->GetPoint(stlgeometry->GetTriangle(j).PNum(k)); glVertex3f (tp.X(), tp.Y(), tp.Z()); } /* for (k = 0; k < 3; k++) { glVertex3f (tria.pts[k].X(), tria.pts[k].Y(), tria.pts[k].Z()); } */ } glEnd (); } } else { int showfilledtrias = vispar.stlshowfilledtrias; //(*mycout) << "in " << showfilledtrias << ", NT=" << stlgeometry -> GetNT() << endl; int chartnumber; if (vispar.stlshowmarktrias) chartnumber = vispar.stlchartnumber + vispar.stlchartnumberoffset; else chartnumber = stlgeometry->GetMeshChartNr(); if (showfilledtrias) { glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); if (colormeshsize) glEnable (GL_COLOR_MATERIAL); glPolygonOffset (pgoff*4, pgoff*4); glEnable (GL_POLYGON_OFFSET_FILL); glEnable (GL_NORMALIZE); glBegin (GL_TRIANGLES); int selt = stlgeometry -> GetSelectTrig(); if (stldoctor.selectmode != 0) {selt = 0; } //do not show selected triangle!!!! glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colstlbody); for (j = 1; j <= stlgeometry -> GetNT(); j++) { if (stldoctor.showvicinity && !stlgeometry->Vicinity(j)) {continue;} if (j == selt) { glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colseltrig); } else if (j == selt+1) { glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colstlbody); } const STLTriangle& st = stlgeometry -> GetTriangle(j); const Vec3d & n = stlgeometry->GetTriangle(j).Normal(); glNormal3f (n.X(), n.Y(), n.Z()); /* const STLReadTriangle& tria = stlgeometry -> GetReadTriangle(j); glNormal3f (tria.normal.X(), tria.normal.Y(), tria.normal.Z()); */ for (k = 0; k < 3; k++) { const Point3d & p = stlgeometry->GetPoint(st[k]); if (colormeshsize) { SetOpenGlColor (mesh->GetH (p), hmin, hmax, 1); } glVertex3f (p.X(), p.Y(), p.Z()); } } glEnd (); } int foundseltrig = stlgeometry -> GetSelectTrig(); if (foundseltrig == 0 || foundseltrig > stlgeometry->GetNT() || (stldoctor.showvicinity && !stlgeometry->Vicinity(foundseltrig))) {foundseltrig = 0;} if (foundseltrig) { glPolygonOffset (pgoff*0, 0); glEnable (GL_POLYGON_OFFSET_FILL); //glDisable (GL_POLYGON_OFFSET_FILL); glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colseledge); glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); glEnable (GL_NORMALIZE); if (stldoctor.selectmode == 2) { //point const STLTriangle& st = stlgeometry -> GetTriangle(foundseltrig); const Point3d & p1 = stlgeometry->GetPoint(st[0]); const Point3d & p2 = stlgeometry->GetPoint(st[1]); const Point3d & p3 = stlgeometry->GetPoint(st[2]); double cs = (Dist(p1,p2)+Dist(p2,p3)+Dist(p3,p1))/100.; const Point3d & p = stlgeometry->GetPoint(st[nodeofseltrig-1]); glLineWidth (4); glBegin (GL_LINES); glVertex3f(p.X()+cs, p.Y()+cs, p.Z()+cs); glVertex3f(p.X()-cs, p.Y()-cs, p.Z()-cs); glVertex3f(p.X()-cs, p.Y()+cs, p.Z()+cs); glVertex3f(p.X()+cs, p.Y()-cs, p.Z()-cs); glVertex3f(p.X()-cs, p.Y()+cs, p.Z()+cs); glVertex3f(p.X()+cs, p.Y()-cs, p.Z()-cs); glVertex3f(p.X()+cs, p.Y()-cs, p.Z()+cs); glVertex3f(p.X()-cs, p.Y()+cs, p.Z()-cs); glEnd (); glLineWidth (1); } else if (stldoctor.selectmode == 1 || stldoctor.selectmode == 3 || stldoctor.selectmode == 4) { //multiedge const Array& me = stlgeometry->SelectedMultiEdge(); if (stlgeometry->GetSelectTrig() > 0 && stlgeometry->GetSelectTrig() <= stlgeometry->GetNT() && me.Size()) { int en = stlgeometry->EdgeDataList().GetEdgeNum(me.Get(1).i1,me.Get(1).i2); int status = stlgeometry->EdgeDataList().Get(en).GetStatus(); switch (status) { case ED_CONFIRMED: glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_collgreen); break; case ED_CANDIDATE: glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_collbrown); break; case ED_EXCLUDED: glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_collred); break; } glLineWidth (2); glBegin (GL_LINES); for (j = 1; j <= me.Size(); j++) { Point3d p1 = stlgeometry->GetPoint(me.Get(j).i1); Point3d p2 = stlgeometry->GetPoint(me.Get(j).i2); glVertex3f(p1.X(), p1.Y(), p1.Z()); glVertex3f(p2.X(), p2.Y(), p2.Z()); } glEnd (); glLineWidth (1); } } } int showmarktrias = vispar.stlshowmarktrias || vispar.stlshowactivechart; if (stldoctor.showmarkedtrigs) { //(*mycout) << "marked" << endl; glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); //GL_LINE glPolygonOffset (pgoff*1, pgoff*1); glEnable (GL_POLYGON_OFFSET_FILL); glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colbluegreen); glEnable (GL_NORMALIZE); glBegin (GL_TRIANGLES); for (j = 1; j <= stlgeometry -> GetNT(); j++) { if (stldoctor.showvicinity && !stlgeometry->Vicinity(j)) {continue;} if (!stlgeometry->IsMarkedTrig(j)) {continue;} const STLTriangle& st = stlgeometry -> GetTriangle(j); const Vec3d & n = stlgeometry->GetTriangle(j).Normal(); glNormal3f (n.X(), n.Y(), n.Z()); /* const STLReadTriangle& tria = stlgeometry -> GetReadTriangle(j); glNormal3f (tria.normal.X(), tria.normal.Y(), tria.normal.Z()); */ for (k = 0; k < 3; k++) { const Point3d & p = stlgeometry->GetPoint(st[k]); glVertex3f (p.X(), p.Y(), p.Z()); } } glEnd (); //show OpenSegments on original geometry glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colviolet); glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); glPolygonOffset (pgoff*1, 1); glEnable (GL_NORMALIZE); glBegin (GL_LINES); if (stlgeometry->GetNMarkedSegs()) { Point<3> p1,p2; for (j = 1; j <= stlgeometry -> GetNMarkedSegs(); j++) { stlgeometry->GetMarkedSeg(j,p1,p2); glVertex3dv(&p1(0)); glVertex3dv(&p2(0)); } } glEnd (); } if (stldoctor.showfaces) { int facenumber = vispar.stlchartnumber + vispar.stlchartnumberoffset; glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); glPolygonOffset (pgoff*3, 3); glEnable (GL_POLYGON_OFFSET_FILL); glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_collgrey); glEnable (GL_NORMALIZE); glBegin (GL_TRIANGLES); for (j = 1; j <= stlgeometry -> GetNT(); j++) { if (stldoctor.showvicinity && !stlgeometry->Vicinity(j)) {continue;} //(*mycout) << " facenum = " << stlgeometry->GetTriangle(j).GetFaceNum() << " "; if (stlgeometry->GetTriangle(j).GetFaceNum() != facenumber) {continue;} const STLTriangle& st = stlgeometry -> GetTriangle(j); const Vec3d & n = stlgeometry->GetTriangle(j).Normal(); glNormal3f (n.X(), n.Y(), n.Z()); /* const STLReadTriangle& tria = stlgeometry -> GetReadTriangle(j); glNormal3f (tria.normal.X(), tria.normal.Y(), tria.normal.Z()); */ for (k = 0; k < 3; k++) { Point3d p = stlgeometry->GetPoint(st[k]); glVertex3f (p.X(), p.Y(), p.Z()); } } glEnd (); } if (showmarktrias && stlgeometry->AtlasMade()) { glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); glPolygonOffset (pgoff*3, 3); glEnable (GL_POLYGON_OFFSET_FILL); glBegin (GL_TRIANGLES); if (chartnumber >= 1 && chartnumber <= stlgeometry->GetNOCharts()) { glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colbrown); const STLChart& chart = stlgeometry->GetChart(chartnumber); for (j = 1; j <= chart.GetNChartT(); j++) { /* if (j == charttrignumber) {glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colred);} else {glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colbrown);} */ const STLTriangle& st = stlgeometry -> GetTriangle(chart.GetChartTrig(j)); const Vec3d & n = stlgeometry->GetTriangle(chart.GetChartTrig(j)).Normal(); glNormal3f (n.X(), n.Y(), n.Z()); /* const STLReadTriangle& tria = stlgeometry -> GetReadTriangle(chart.GetChartTrig(j)); glNormal3f (tria.normal.X(), tria.normal.Y(), tria.normal.Z()); */ for (k = 0; k < 3; k++) { glVertex3f (stlgeometry->GetPoint(st[k])(0), stlgeometry->GetPoint(st[k])(1), stlgeometry->GetPoint(st[k])(2)); } } glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colgreen); for (j = 1; j <= chart.GetNOuterT(); j++) { const STLTriangle& st = stlgeometry -> GetTriangle(chart.GetOuterTrig(j)); const Vec3d & n = stlgeometry->GetTriangle(chart.GetOuterTrig(j)).Normal(); glNormal3f (n.X(), n.Y(), n.Z()); /* const STLReadTriangle& tria = stlgeometry -> GetReadTriangle(chart.GetOuterTrig(j)); glNormal3f (tria.normal.X(), tria.normal.Y(), tria.normal.Z()); */ for (k = 0; k < 3; k++) { glVertex3f (stlgeometry->GetPoint(st[k])(0), stlgeometry->GetPoint(st[k])(1), stlgeometry->GetPoint(st[k])(2)); } } } glEnd (); } int showtrias = vispar.stlshowtrias; if (showtrias) { glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colgrey); glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); glPolygonOffset (pgoff*2, 2); glEnable (GL_POLYGON_OFFSET_FILL); glEnable (GL_NORMALIZE); glBegin (GL_TRIANGLES); for (j = 1; j <= stlgeometry -> GetNT(); j++) { if (stldoctor.showvicinity && !stlgeometry->Vicinity(j)) {continue;} const STLTriangle& st = stlgeometry -> GetTriangle(j); const Vec3d & n = stlgeometry->GetTriangle(j).Normal(); glNormal3f (n.X(), n.Y(), n.Z()); /* const STLReadTriangle& tria = stlgeometry -> GetReadTriangle(j); glNormal3f (tria.normal.X(), tria.normal.Y(), tria.normal.Z()); */ for (k = 0; k < 3; k++) { glVertex3f (stlgeometry->GetPoint(st[k])(0), stlgeometry->GetPoint(st[k])(1), stlgeometry->GetPoint(st[k])(2)); } } glEnd (); } int showedges = vispar.stlshowedges; if (showedges) { glPolygonOffset (pgoff*1, 1); glEnable (GL_POLYGON_OFFSET_FILL); //glDisable (GL_POLYGON_OFFSET_FILL); glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colgreen); glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); glEnable (GL_NORMALIZE); glBegin (GL_LINES); /* if (stldoctor.useexternaledges) { glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colorange); for (j = 1; j <= stlgeometry -> NOExternalEdges(); j++) { twoint v = stlgeometry->GetExternalEdge(j); Point3d p1 = stlgeometry->GetPoint(v.i1); Point3d p2 = stlgeometry->GetPoint(v.i2); Vec3d n1 = stlgeometry->GetNormal(v.i1); Vec3d n2 = stlgeometry->GetNormal(v.i2); glNormal3f(n1.X(), n1.Y(), n1.Z()); glVertex3f(p1.X(), p1.Y(), p1.Z()); glNormal3f(n2.X(), n2.Y(), n2.Z()); glVertex3f(p2.X(), p2.Y(), p2.Z()); } } */ if (!stlgeometry->meshlines.Size() || !stldoctor.drawmeshededges) { /* for (j = 1; j <= stlgeometry -> GetNE(); j++) { STLEdge v = stlgeometry->GetEdge(j); Point3d p1 = stlgeometry->GetPoint(v.pts[0]); Point3d p2 = stlgeometry->GetPoint(v.pts[1]); Vec3d n1 = stlgeometry->GetNormal(v.pts[0]); Vec3d n2 = stlgeometry->GetNormal(v.pts[1]); glNormal3f(n1.X(), n1.Y(), n1.Z()); glVertex3f(p1.X(), p1.Y(), p1.Z()); glNormal3f(n2.X(), n2.Y(), n2.Z()); glVertex3f(p2.X(), p2.Y(), p2.Z()); } */ const STLEdgeDataList& ed = stlgeometry->EdgeDataList(); for (i = 1; i <= ed.Size(); i++) { if (ed.Get(i).GetStatus() != ED_UNDEFINED) { switch (ed.Get(i).GetStatus()) { case ED_CONFIRMED: glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colgreen); break; case ED_CANDIDATE: glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colbrown); break; case ED_EXCLUDED: glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colred); break; } if (ed.Get(i).GetStatus() == ED_EXCLUDED && !stldoctor.showexcluded) continue; Point3d p1 = stlgeometry->GetPoint(ed.Get(i).PNum(1)); Point3d p2 = stlgeometry->GetPoint(ed.Get(i).PNum(2)); glVertex3f(p1.X(), p1.Y(), p1.Z()); glVertex3f(p2.X(), p2.Y(), p2.Z()); } } } /* else if (stlgeometry->meshlines.Size() == 0) { for (j = 1; j <= stlgeometry->GetNLines(); j++) { STLLine* line = stlgeometry->GetLine(j); int pn1, pn2; for (int k = 1; k <= line->NP()-1; k++) { pn1 = line->PNum(k); pn2 = line->PNum(k+1); Point3d p1 = stlgeometry->GetPoint(pn1); Point3d p2 = stlgeometry->GetPoint(pn2); Vec3d n1 = stlgeometry->GetNormal(pn1); Vec3d n2 = stlgeometry->GetNormal(pn2); glNormal3f(n1.X(), n1.Y(), n1.Z()); glVertex3f(p1.X(), p1.Y(), p1.Z()); glNormal3f(n2.X(), n2.Y(), n2.Z()); glVertex3f(p2.X(), p2.Y(), p2.Z()); } } } */ else if (stlgeometry->meshlines.Size() != 0) { glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colgreen); for (j = 1; j <= stlgeometry->meshlines.Size(); j++) { STLLine* line = stlgeometry->meshlines.Get(j); int pn1, pn2; for (int k = 1; k <= line->NP()-1; k++) { pn1 = line->PNum(k); pn2 = line->PNum(k+1); Point3d p1 = stlgeometry->meshpoints.Get(pn1); Point3d p2 = stlgeometry->meshpoints.Get(pn2); glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colgreen); glVertex3f(p1.X(), p1.Y(), p1.Z()); glVertex3f(p2.X(), p2.Y(), p2.Z()); glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colred); double cs = 0.02*Dist(p1,p2); glVertex3f(p1.X()+cs, p1.Y()+cs, p1.Z()+cs); glVertex3f(p1.X()-cs, p1.Y()-cs, p1.Z()-cs); glVertex3f(p2.X()+cs, p2.Y()+cs, p2.Z()+cs); glVertex3f(p2.X()-cs, p2.Y()-cs, p2.Z()-cs); glVertex3f(p1.X()-cs, p1.Y()+cs, p1.Z()+cs); glVertex3f(p1.X()+cs, p1.Y()-cs, p1.Z()-cs); glVertex3f(p2.X()-cs, p2.Y()+cs, p2.Z()+cs); glVertex3f(p2.X()+cs, p2.Y()-cs, p2.Z()-cs); } } } glEnd (); } if (stldoctor.showedgecornerpoints && stlgeometry->LineEndPointsSet()) { glPointSize (5); glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colred); glBegin (GL_POINTS); for (i = 1; i <= stlgeometry->GetNP(); i++) { if (stlgeometry->IsLineEndPoint(i)) { const Point3d p = stlgeometry->GetPoint(i); glVertex3f (p.X(), p.Y(), p.Z()); } } glEnd(); } } glPopMatrix(); if (vispar.colormeshsize) DrawColorBar (hmin, hmax, 1); glFinish(); } void VisualSceneSTLMeshing :: BuildScene (int zoomall) { if (selecttrig && zoomall == 2) center = stlgeometry -> GetPoint ( stlgeometry->GetTriangle(selecttrig).PNum(nodeofseltrig)); else center = stlgeometry -> GetBoundingBox().Center(); rad = stlgeometry -> GetBoundingBox().Diam() / 2; CalcTransformationMatrices(); } void VisualSceneSTLMeshing :: MouseDblClick (int px, int py) { // (*mycout) << "dblclick: " << px << " - " << py << endl; int i, j, k, hits; // select surface triangle by mouse click GLuint selbuf[10000]; glSelectBuffer (10000, selbuf); glRenderMode (GL_SELECT); GLint viewport[4]; glGetIntegerv (GL_VIEWPORT, viewport); /* (*mycout) << "viewport = " << viewport[0] << " " << viewport[1] << " " << viewport[2] << " " << viewport[3] << endl; */ glMatrixMode (GL_PROJECTION); glPushMatrix(); GLdouble projmat[16]; glGetDoublev (GL_PROJECTION_MATRIX, projmat); glLoadIdentity(); gluPickMatrix (px, viewport[3] - py, 1, 1, viewport); glMultMatrixd (projmat); glClearColor(backcolor, backcolor, backcolor, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode (GL_MODELVIEW); glPushMatrix(); glMultMatrixf (transformationmat); glInitNames(); glPushName (1); glEnable (GL_POLYGON_OFFSET_FILL); for (j = 1; j <= stlgeometry -> GetNT(); j++) { if (stldoctor.showvicinity && !stlgeometry->Vicinity(j)) {continue;} const STLTriangle& st = stlgeometry -> GetTriangle(j); //const STLReadTriangle& tria = stlgeometry -> GetReadTriangle(j); //glNormal3f (tria.normal.X(), tria.normal.Y(), tria.normal.Z()); if (stldoctor.selectmode == 0) { glLoadName (j); glBegin (GL_TRIANGLES); for (k = 0; k < 3; k++) { Point3d p = stlgeometry->GetPoint(st[k]); glVertex3f (p.X(), p.Y(), p.Z()); } glEnd (); } else if (stldoctor.selectmode == 1 || stldoctor.selectmode == 3 || stldoctor.selectmode == 4) { Point3d pm = Center(stlgeometry->GetPoint(st[0]), stlgeometry->GetPoint(st[1]), stlgeometry->GetPoint(st[2])); for (k = 0; k < 3; k++) { glLoadName (j*3+k-2); glBegin (GL_TRIANGLES); Point3d p1 = stlgeometry->GetPoint(st[k]); Point3d p2 = stlgeometry->GetPoint(st[(k+1)%3]); glVertex3f (p1.X(), p1.Y(), p1.Z()); glVertex3f (p2.X(), p2.Y(), p2.Z()); glVertex3f (pm.X(), pm.Y(), pm.Z()); glEnd (); } } else { Point3d pm1 = Center(stlgeometry->GetPoint(st[0]), stlgeometry->GetPoint(st[1])); Point3d pm2 = Center(stlgeometry->GetPoint(st[1]), stlgeometry->GetPoint(st[2])); Point3d pm3 = Center(stlgeometry->GetPoint(st[2]), stlgeometry->GetPoint(st[0])); Point3d p1 = stlgeometry->GetPoint(st[0]); Point3d p2 = stlgeometry->GetPoint(st[1]); Point3d p3 = stlgeometry->GetPoint(st[2]); glLoadName (j*4-3); glBegin (GL_TRIANGLES); glVertex3f (p1.X(), p1.Y(), p1.Z()); glVertex3f (pm1.X(), pm1.Y(), pm1.Z()); glVertex3f (pm3.X(), pm3.Y(), pm3.Z()); glEnd (); glLoadName (j*4-2); glBegin (GL_TRIANGLES); glVertex3f (p2.X(), p2.Y(), p2.Z()); glVertex3f (pm2.X(), pm2.Y(), pm2.Z()); glVertex3f (pm1.X(), pm1.Y(), pm1.Z()); glEnd (); glLoadName (j*4-1); glBegin (GL_TRIANGLES); glVertex3f (p3.X(), p3.Y(), p3.Z()); glVertex3f (pm3.X(), pm3.Y(), pm3.Z()); glVertex3f (pm2.X(), pm2.Y(), pm2.Z()); glEnd (); glLoadName (j*4); glBegin (GL_TRIANGLES); glVertex3f (pm1.X(), pm1.Y(), pm1.Z()); glVertex3f (pm2.X(), pm2.Y(), pm2.Z()); glVertex3f (pm3.X(), pm3.Y(), pm3.Z()); glEnd (); } } glPopName(); glMatrixMode (GL_PROJECTION); glPopMatrix(); glMatrixMode (GL_MODELVIEW); glPopMatrix(); glFlush(); hits = glRenderMode (GL_RENDER); // (*mycout) << "hits = " << hits << endl; //int minrec = -1; int minname = 0; GLuint mindepth = 0; for (i = 0; i < hits; i++) { int curname = selbuf[4*i+3]; GLuint curdepth = selbuf[4*i+1]; /* (*mycout) << selbuf[4*i] << " " << selbuf[4*i+1] << " " << selbuf[4*i+2] << " " << selbuf[4*i+3] << endl; */ if (curname && (curdepth < mindepth || !minname)) { //minrec = i; mindepth = curdepth; minname = curname; } } if (!minname) {return;} if (stldoctor.selectmode == 0) { int oldtrig = selecttrig; selecttrig = minname; if (selecttrig == oldtrig) nodeofseltrig = (nodeofseltrig % 3) + 1; else nodeofseltrig = 1; stlgeometry->SetSelectTrig(selecttrig); stlgeometry->SetNodeOfSelTrig(nodeofseltrig); stlgeometry->PrintSelectInfo(); } else if (stldoctor.selectmode == 1 || stldoctor.selectmode == 3 || stldoctor.selectmode == 4) { selecttrig = (minname-1) / 3 + 1; nodeofseltrig = minname-selecttrig*3+3; stlgeometry->SetSelectTrig(selecttrig); stlgeometry->SetNodeOfSelTrig(nodeofseltrig); stlgeometry->PrintSelectInfo(); if (stldoctor.selectmode == 1) { stlgeometry->BuildSelectedEdge(twoint(stlgeometry->GetTriangle(selecttrig).PNumMod(nodeofseltrig), stlgeometry->GetTriangle(selecttrig).PNumMod(nodeofseltrig+1))); } if (stldoctor.selectmode == 3) { stlgeometry->BuildSelectedMultiEdge(twoint(stlgeometry->GetTriangle(selecttrig).PNumMod(nodeofseltrig), stlgeometry->GetTriangle(selecttrig).PNumMod(nodeofseltrig+1))); } else if (stldoctor.selectmode == 4) { stlgeometry->BuildSelectedCluster(twoint(stlgeometry->GetTriangle(selecttrig).PNumMod(nodeofseltrig), stlgeometry->GetTriangle(selecttrig).PNumMod(nodeofseltrig+1))); } switch (stldoctor.edgeselectmode) { case 1: stlgeometry->STLDoctorUndefinedEdge(); break; case 2: stlgeometry->STLDoctorConfirmEdge(); break; case 3: stlgeometry->STLDoctorCandidateEdge(); break; case 4: stlgeometry->STLDoctorExcludeEdge(); break; default: break; } } else if (stldoctor.selectmode == 2) { selecttrig = (minname-1) / 4 + 1; nodeofseltrig = minname-selecttrig*4+4; if (nodeofseltrig == 4) {nodeofseltrig = 1;} stlgeometry->SetSelectTrig(selecttrig); stlgeometry->SetNodeOfSelTrig(nodeofseltrig); stlgeometry->PrintSelectInfo(); } if (stldoctor.showtouchedtrigchart && stlgeometry->AtlasMade() && stlgeometry->GetSelectTrig()) { vispar.stlchartnumber = stlgeometry->GetChartNr(stlgeometry->GetSelectTrig()); vispar.stlchartnumberoffset = 0; } } VisualSceneSTLMeshing vsstlmeshing; #endif } netgen-4.9.13/libsrc/visualization/soldata.hpp0000644000175000001440000000400011351622320016311 00000000000000#ifndef FILE_SOLDATA #define FILE_SOLDATA namespace netgen { using namespace std; class DLL_HEADER SolutionData { protected: string name; int components; bool iscomplex; int multidimcomponent; public: SolutionData (const string & aname, int acomponents = 1, bool aiscomplex = 0) : name(aname), components(acomponents), iscomplex(aiscomplex) { ; } virtual ~SolutionData () { ; } int GetComponents() { return components; } bool IsComplex() { return iscomplex; } virtual bool GetValue (int /* elnr */, double /* lam1 */, double /* lam2 */, double /* lam3 */, double * /* values */) { return false; } virtual bool GetValue (int selnr, const double xref[], const double x[], const double dxdxref[], double * values) { return GetValue (selnr, xref[0], xref[1], xref[2], values); } virtual bool GetMultiValue (int elnr, int npts, const double * xref, int sxref, const double * x, int sx, const double * dxdxref, int sdxdxref, double * values, int svalues); virtual bool GetSurfValue (int /* selnr */, double /* lam1 */, double /* lam2 */, double * /* values */) { return false; } virtual bool GetSurfValue (int selnr, const double xref[], const double x[], const double dxdxref[], double * values) { return GetSurfValue (selnr, xref[0], xref[1], values); } virtual bool GetMultiSurfValue (int selnr, int npts, const double * xref, int sxref, const double * x, int sx, const double * dxdxref, int sdxdxref, double * values, int svalues); void SetMultiDimComponent (int mc) { multidimcomponent = mc; } }; } #endif netgen-4.9.13/libsrc/visualization/vispar.hpp0000644000175000001440000000336011240003502016166 00000000000000#ifndef FILE_VISPAR #define FILE_VISPAR namespace netgen { class VisualizationParameters { public: double lightamb; double lightdiff; double lightspec; double shininess; double transp; int locviewer; char selectvisual[20]; int showstltrias; Vec3d clipnormal; double clipdist; int clipenable; int clipplanetimestamp; int colormeshsize; int drawfilledtrigs; int drawbadels; int drawoutline; int drawedges; int subdivisions; int drawprisms; int drawpyramids; int drawhexes; double shrink; int drawidentified; int drawpointnumbers; int drawedgenumbers; int drawfacenumbers; int drawelementnumbers; int drawdomainsurf; int drawtets; int drawtetsdomain; int clipdomain; int donotclipdomain; int drawededges; int drawedpoints; int drawedpointnrs; int drawedtangents; int drawededgenrs; int drawmetispartition; int drawcurveproj; int drawcurveprojedge; int centerpoint; int drawelement; // stl: int stlshowtrias; int stlshowfilledtrias; int stlshowedges; int stlshowmarktrias; int stlshowactivechart; int stlchartnumber; int stlchartnumberoffset; // occ: int occshowvolumenr; bool occshowsurfaces; bool occshowedges; bool occvisproblemfaces; bool occzoomtohighlightedentity; double occdeflection; // ACIS bool ACISshowfaces; bool ACISshowedges; int ACISshowsolidnr; int ACISshowsolidnr2; bool whitebackground; int stereo; bool usedispllists; bool drawcoordinatecross; bool drawcolorbar; bool drawnetgenlogo; bool use_center_coords; double centerx,centery,centerz; bool drawspecpoint; double specpointx,specpointy,specpointz; public: VisualizationParameters(); }; extern VisualizationParameters vispar; } #endif netgen-4.9.13/libsrc/stlgeom/0000777000175000001440000000000011377017541013027 500000000000000netgen-4.9.13/libsrc/stlgeom/stltopology.cpp0000644000175000001440000005175611240003503016042 00000000000000#include #include #include #include #include #include "stlgeom.hpp" namespace netgen { STLTopology :: STLTopology() : trias(), topedges(), points(), ht_topedges(NULL), neighbourtrigs(), trigsperpoint() { ; } STLTopology :: ~STLTopology() { ; } STLGeometry * STLTopology :: LoadBinary (istream & ist) { STLGeometry * geom = new STLGeometry(); Array readtrigs; PrintMessage(1,"Read STL binary file"); if (sizeof(int) != 4 || sizeof(float) != 4) { PrintWarning("for stl-binary compatibility only use 32 bit compilation!!!"); } //specific settings for stl-binary format const int namelen = 80; //length of name of header in file const int nospaces = 2; //number of spaces after a triangle //read header: name char buf[namelen+1]; FIOReadStringE(ist,buf,namelen); PrintMessage(5,"header = ",buf); //Read Number of facets int nofacets; FIOReadInt(ist,nofacets); PrintMessage(5,"NO facets = ",nofacets); Point<3> pts[3]; Vec<3> normal; int cntface, j; //int vertex = 0; float f; char spaces[nospaces+1]; for (cntface = 0; cntface < nofacets; cntface++) { if (cntface % 10000 == 9999) { PrintDot(); } FIOReadFloat(ist,f); normal(0) = f; FIOReadFloat(ist,f); normal(1) = f; FIOReadFloat(ist,f); normal(2) = f; for (j = 0; j < 3; j++) { FIOReadFloat(ist,f); pts[j](0) = f; FIOReadFloat(ist,f); pts[j](1) = f; FIOReadFloat(ist,f); pts[j](2) = f; } readtrigs.Append (STLReadTriangle (pts, normal)); FIOReadString(ist,spaces,nospaces); } geom->InitSTLGeometry(readtrigs); return geom; } void STLTopology :: SaveBinary (const char* filename, const char* aname) { ofstream ost(filename); PrintFnStart("Write STL binary file '",filename,"'"); if (sizeof(int) != 4 || sizeof(float) != 4) {PrintWarning("for stl-binary compatibility only use 32 bit compilation!!!");} //specific settings for stl-binary format const int namelen = 80; //length of name of header in file const int nospaces = 2; //number of spaces after a triangle //write header: aname int i, j; char buf[namelen+1]; int strend = 0; for(i = 0; i <= namelen; i++) { if (aname[i] == 0) {strend = 1;} if (!strend) {buf[i] = aname[i];} else {buf[i] = 0;} } FIOWriteString(ost,buf,namelen); PrintMessage(5,"header = ",buf); //RWrite Number of facets int nofacets = GetNT(); FIOWriteInt(ost,nofacets); PrintMessage(5,"NO facets = ", nofacets); float f; char spaces[nospaces+1]; for (i = 0; i < nospaces; i++) {spaces[i] = ' ';} spaces[nospaces] = 0; for (i = 1; i <= GetNT(); i++) { const STLTriangle & t = GetTriangle(i); const Vec<3> & n = t.Normal(); f = n(0); FIOWriteFloat(ost,f); f = n(1); FIOWriteFloat(ost,f); f = n(2); FIOWriteFloat(ost,f); for (j = 1; j <= 3; j++) { const Point3d p = GetPoint(t.PNum(j)); f = p.X(); FIOWriteFloat(ost,f); f = p.Y(); FIOWriteFloat(ost,f); f = p.Z(); FIOWriteFloat(ost,f); } FIOWriteString(ost,spaces,nospaces); } PrintMessage(5,"done"); } void STLTopology :: SaveSTLE (const char* filename) { ofstream outf (filename); int i, j; outf << GetNT() << endl; for (i = 1; i <= GetNT(); i++) { const STLTriangle & t = GetTriangle(i); for (j = 1; j <= 3; j++) { const Point3d p = GetPoint(t.PNum(j)); outf << p.X() << " " << p.Y() << " " << p.Z() << endl; } } int ned = 0; for (i = 1; i <= GetNTE(); i++) { if (GetTopEdge (i).GetStatus() == ED_CONFIRMED) ned++; } outf << ned << endl; for (i = 1; i <= GetNTE(); i++) { const STLTopEdge & edge = GetTopEdge (i); if (edge.GetStatus() == ED_CONFIRMED) for (j = 1; j <= 2; j++) { const Point3d p = GetPoint(edge.PNum(j)); outf << p.X() << " " << p.Y() << " " << p.Z() << endl; } } } STLGeometry * STLTopology :: LoadNaomi (istream & ist) { int i; STLGeometry * geom = new STLGeometry(); Array readtrigs; PrintFnStart("read NAOMI file format"); char buf[100]; Vec<3> normal; //int cntface = 0; //int cntvertex = 0; double px, py, pz; int noface, novertex; Array > readpoints; ist >> buf; if (strcmp (buf, "NODES") == 0) { ist >> novertex; PrintMessage(5,"nuber of vertices = ", novertex); for (i = 0; i < novertex; i++) { ist >> px; ist >> py; ist >> pz; readpoints.Append(Point<3> (px,py,pz)); } } else { PrintFileError("no node information"); } ist >> buf; if (strcmp (buf, "2D_EDGES") == 0) { ist >> noface; PrintMessage(5,"number of faces=",noface); int dummy, p1, p2, p3; Point<3> pts[3]; for (i = 0; i < noface; i++) { ist >> dummy; //2 ist >> dummy; //1 ist >> p1; ist >> p2; ist >> p3; ist >> dummy; //0 pts[0] = readpoints.Get(p1); pts[1] = readpoints.Get(p2); pts[2] = readpoints.Get(p3); normal = Cross (pts[1]-pts[0], pts[2]-pts[0]) . Normalize(); readtrigs.Append (STLReadTriangle (pts, normal)); } PrintMessage(5,"read ", readtrigs.Size(), " triangles"); } else { PrintMessage(5,"read='",buf,"'\n"); PrintFileError("ERROR: no Triangle information"); } geom->InitSTLGeometry(readtrigs); return geom; } void STLTopology :: Save (const char* filename) { PrintFnStart("Write stl-file '",filename, "'"); ofstream fout(filename); fout << "solid\n"; char buf1[50]; char buf2[50]; char buf3[50]; int i, j; for (i = 1; i <= GetNT(); i++) { const STLTriangle & t = GetTriangle(i); fout << "facet normal "; const Vec3d& n = GetTriangle(i).Normal(); sprintf(buf1,"%1.9g",n.X()); sprintf(buf2,"%1.9g",n.Y()); sprintf(buf3,"%1.9g",n.Z()); fout << buf1 << " " << buf2 << " " << buf3 << "\n"; fout << "outer loop\n"; for (j = 1; j <= 3; j++) { const Point3d p = GetPoint(t.PNum(j)); sprintf(buf1,"%1.9g",p.X()); sprintf(buf2,"%1.9g",p.Y()); sprintf(buf3,"%1.9g",p.Z()); fout << "vertex " << buf1 << " " << buf2 << " " << buf3 << "\n"; } fout << "endloop\n"; fout << "endfacet\n"; } fout << "endsolid\n"; // write also NETGEN surface mesh: ofstream fout2("geom.surf"); fout2 << "surfacemesh" << endl; fout2 << GetNP() << endl; for (i = 1; i <= GetNP(); i++) { for (j = 0; j < 3; j++) { fout2.width(8); fout2 << GetPoint(i)(j); } fout2 << endl; } fout2 << GetNT() << endl; for (i = 1; i <= GetNT(); i++) { const STLTriangle & t = GetTriangle(i); for (j = 1; j <= 3; j++) { fout2.width(8); fout2 << t.PNum(j); } fout2 << endl; } } STLGeometry * STLTopology ::Load (istream & ist) { size_t i; STLGeometry * geom = new STLGeometry(); Array readtrigs; char buf[100]; Point<3> pts[3]; Vec<3> normal; int cntface = 0; int vertex = 0; bool badnormals = 0; while (ist.good()) { ist >> buf; size_t n = strlen (buf); for (i = 0; i < n; i++) buf[i] = tolower (buf[i]); if (strcmp (buf, "facet") == 0) { cntface++; } if (strcmp (buf, "normal") == 0) { ist >> normal(0) >> normal(1) >> normal(2); normal.Normalize(); } if (strcmp (buf, "vertex") == 0) { ist >> pts[vertex](0) >> pts[vertex](1) >> pts[vertex](2); vertex++; if (vertex == 3) { if (normal.Length() <= 1e-5) { normal = Cross (pts[1]-pts[0], pts[2]-pts[0]); normal.Normalize(); } else { Vec<3> hnormal; hnormal = Cross (pts[1]-pts[0], pts[2]-pts[0]); hnormal.Normalize(); if (normal * hnormal < 0.5) { badnormals = 1; } } vertex = 0; if ( (Dist2 (pts[0], pts[1]) > 1e-16) && (Dist2 (pts[0], pts[2]) > 1e-16) && (Dist2 (pts[1], pts[2]) > 1e-16) ) readtrigs.Append (STLReadTriangle (pts, normal)); } } } if (badnormals) { PrintWarning("File has normal vectors which differ extremly from geometry->correct with stldoctor!!!"); } geom->InitSTLGeometry(readtrigs); return geom; } void STLTopology :: InitSTLGeometry(const Array & readtrigs) { int i, k; // const double geometry_tol_fact = 1E6; // distances lower than max_box_size/tol are ignored trias.SetSize(0); points.SetSize(0); PrintMessage(3,"number of triangles = ", readtrigs.Size()); if (!readtrigs.Size()) return; boundingbox.Set (readtrigs[0][0]); for (i = 0; i < readtrigs.Size(); i++) for (k = 0; k < 3; k++) boundingbox.Add (readtrigs[i][k]); PrintMessage(5,"boundingbox: ", Point3d(boundingbox.PMin()), " - ", Point3d(boundingbox.PMax())); Box<3> bb = boundingbox; bb.Increase (1); pointtree = new Point3dTree (bb.PMin(), bb.PMax()); Array pintersect; pointtol = boundingbox.Diam() * stldoctor.geom_tol_fact; PrintMessage(5,"point tolerance = ", pointtol); for(i = 0; i < readtrigs.Size(); i++) { const STLReadTriangle & t = readtrigs[i]; STLTriangle st; Vec<3> n = t.Normal(); st.SetNormal (t.Normal()); for (k = 0; k < 3; k++) { Point<3> p = t[k]; Point<3> pmin = p - Vec<3> (pointtol, pointtol, pointtol); Point<3> pmax = p + Vec<3> (pointtol, pointtol, pointtol); pointtree->GetIntersecting (pmin, pmax, pintersect); if (pintersect.Size() > 1) PrintError("too many close points"); int foundpos = -1; if (pintersect.Size()) foundpos = pintersect[0]; if (foundpos == -1) { foundpos = AddPoint(p); pointtree->Insert (p, foundpos); } st[k] = foundpos; } if ( (st[0] == st[1]) || (st[0] == st[2]) || (st[1] == st[2]) ) { PrintError("STL Triangle degenerated"); } else { AddTriangle(st); } } FindNeighbourTrigs(); } int STLTopology :: GetPointNum (const Point<3> & p) { Point<3> pmin = p - Vec<3> (pointtol, pointtol, pointtol); Point<3> pmax = p + Vec<3> (pointtol, pointtol, pointtol); Array pintersect; pointtree->GetIntersecting (pmin, pmax, pintersect); if (pintersect.Size() == 1) return pintersect[0]; else return 0; } void STLTopology :: FindNeighbourTrigs() { // if (topedges.Size()) return; PushStatusF("Find Neighbour Triangles"); int i, j, k, l; // build up topology tables //int np = GetNP(); int nt = GetNT(); INDEX_2_HASHTABLE * oldedges = ht_topedges; ht_topedges = new INDEX_2_HASHTABLE (GetNP()+1); topedges.SetSize(0); for (i = 1; i <= nt; i++) { STLTriangle & trig = GetTriangle(i); for (j = 1; j <= 3; j++) { int pi1 = trig.PNumMod (j+1); int pi2 = trig.PNumMod (j+2); INDEX_2 i2(pi1, pi2); i2.Sort(); int enr; int othertn; if (ht_topedges->Used(i2)) { enr = ht_topedges->Get(i2); topedges.Elem(enr).TrigNum(2) = i; othertn = topedges.Get(enr).TrigNum(1); STLTriangle & othertrig = GetTriangle(othertn); trig.NBTrigNum(j) = othertn; trig.EdgeNum(j) = enr; for (k = 1; k <= 3; k++) if (othertrig.EdgeNum(k) == enr) othertrig.NBTrigNum(k) = i; } else { enr = topedges.Append (STLTopEdge (pi1, pi2, i, 0)); ht_topedges->Set (i2, enr); trig.EdgeNum(j) = enr; } } } PrintMessage(5,"topology built, checking"); topology_ok = 1; int ne = GetNTE(); for (i = 1; i <= nt; i++) GetTriangle(i).flags.toperror = 0; for (i = 1; i <= nt; i++) for (j = 1; j <= 3; j++) { const STLTopEdge & edge = GetTopEdge (GetTriangle(i).EdgeNum(j)); if (edge.TrigNum(1) != i && edge.TrigNum(2) != i) { topology_ok = 0; GetTriangle(i).flags.toperror = 1; } } for (i = 1; i <= ne; i++) { const STLTopEdge & edge = GetTopEdge (i); if (!edge.TrigNum(2)) { topology_ok = 0; GetTriangle(edge.TrigNum(1)).flags.toperror = 1; } } if (topology_ok) { orientation_ok = 1; for (i = 1; i <= nt; i++) { const STLTriangle & t = GetTriangle (i); for (j = 1; j <= 3; j++) { const STLTriangle & nbt = GetTriangle (t.NBTrigNum(j)); if (!t.IsNeighbourFrom (nbt)) orientation_ok = 0; } } } else orientation_ok = 0; status = STL_GOOD; statustext = ""; if (!topology_ok || !orientation_ok) { status = STL_ERROR; if (!topology_ok) statustext = "Topology not ok"; else statustext = "Orientation not ok"; } PrintMessage(3,"topology_ok = ",topology_ok); PrintMessage(3,"orientation_ok = ",orientation_ok); PrintMessage(3,"topology found"); // generate point -> trig table trigsperpoint.SetSize(GetNP()); for (i = 1; i <= GetNT(); i++) for (j = 1; j <= 3; j++) trigsperpoint.Add1(GetTriangle(i).PNum(j),i); //check trigs per point: /* for (i = 1; i <= GetNP(); i++) { if (trigsperpoint.EntrySize(i) < 3) { (*testout) << "ERROR: Point " << i << " has " << trigsperpoint.EntrySize(i) << " triangles!!!" << endl; } } */ topedgesperpoint.SetSize (GetNP()); for (i = 1; i <= ne; i++) for (j = 1; j <= 2; j++) topedgesperpoint.Add1 (GetTopEdge (i).PNum(j), i); PrintMessage(5,"point -> trig table generated"); // transfer edge data: // .. to be done delete oldedges; for (STLTrigIndex ti = 0; ti < GetNT(); ti++) { STLTriangle & trig = trias[ti]; for (k = 0; k < 3; k++) { STLPointIndex pi = trig[k] - STLBASE; STLPointIndex pi2 = trig[(k+1)%3] - STLBASE; STLPointIndex pi3 = trig[(k+2)%3] - STLBASE; // vector along edge Vec<3> ve = points[pi2] - points[pi]; ve.Normalize(); // vector along third point Vec<3> vt = points[pi3] - points[pi]; vt -= (vt * ve) * ve; vt.Normalize(); Vec<3> vn = trig.GeomNormal (points); vn.Normalize(); double phimin = 10, phimax = -1; // out of (0, 2 pi) for (j = 0; j < trigsperpoint[pi].Size(); j++) { STLTrigIndex ti2 = trigsperpoint[pi][j] - STLBASE; const STLTriangle & trig2 = trias[ti2]; if (ti == ti2) continue; bool hasboth = 0; for (l = 0; l < 3; l++) if (trig2[l] - STLBASE == pi2) { hasboth = 1; break; } if (!hasboth) continue; STLPointIndex pi4(0); for (l = 0; l < 3; l++) if (trig2[l] - STLBASE != pi && trig2[l] - STLBASE != pi2) pi4 = trig2[l] - STLBASE; Vec<3> vt2 = points[pi4] - points[pi]; double phi = atan2 (vt2 * vn, vt2 * vt); if (phi < 0) phi += 2 * M_PI; if (phi < phimin) { phimin = phi; trig.NBTrig (0, (k+2)%3) = ti2 + STLBASE; } if (phi > phimax) { phimax = phi; trig.NBTrig (1, (k+2)%3) = ti2 + STLBASE; } } } } if (status == STL_GOOD) { // for compatibility: neighbourtrigs.SetSize(GetNT()); for (i = 1; i <= GetNT(); i++) for (k = 1; k <= 3; k++) AddNeighbourTrig (i, GetTriangle(i).NBTrigNum(k)); } else { // assemble neighbourtrigs (should be done only for illegal topology): neighbourtrigs.SetSize(GetNT()); int tr, found; int wrongneighbourfound = 0; for (i = 1; i <= GetNT(); i++) { SetThreadPercent((double)i/(double)GetNT()*100.); if (multithread.terminate) { PopStatus(); return; } for (k = 1; k <= 3; k++) { for (j = 1; j <= trigsperpoint.EntrySize(GetTriangle(i).PNum(k)); j++) { tr = trigsperpoint.Get(GetTriangle(i).PNum(k),j); if (i != tr && (GetTriangle(i).IsNeighbourFrom(GetTriangle(tr)) || GetTriangle(i).IsWrongNeighbourFrom(GetTriangle(tr)))) { if (GetTriangle(i).IsWrongNeighbourFrom(GetTriangle(tr))) { /*(*testout) << "ERROR: triangle " << i << " has a wrong neighbour triangle!!!" << endl;*/ wrongneighbourfound ++; } found = 0; for (int ii = 1; ii <= NONeighbourTrigs(i); ii++) {if (NeighbourTrig(i,ii) == tr) {found = 1;break;};} if (! found) {AddNeighbourTrig(i,tr);} } } } if (NONeighbourTrigs(i) != 3) { PrintError("TRIG ",i," has ",NONeighbourTrigs(i)," neighbours!!!!"); for (int kk=1; kk <= NONeighbourTrigs(i); kk++) { PrintMessage(5,"neighbour-trig",kk," = ",NeighbourTrig(i,kk)); } }; } if (wrongneighbourfound) { PrintError("++++++++++++++++++++\n"); PrintError(wrongneighbourfound, " wrong oriented neighbourtriangles found!"); PrintError("try to correct it (with stldoctor)!"); PrintError("++++++++++++++++++++\n"); status = STL_ERROR; statustext = "STL Mesh not consistent"; multithread.terminate = 1; #ifdef STAT_STREAM (*statout) << "non-conform stl geometry \\hline" << endl; #endif } } TopologyChanged(); PopStatus(); } void STLTopology :: GetTrianglesInBox (/* const Point<3> & pmin, const Point<3> & pmax, */ const Box<3> & box, Array & btrias) const { if (searchtree) searchtree -> GetIntersecting (box.PMin(), box.PMax(), btrias); else { int i; Box<3> box1 = box; box1.Increase (1e-4); btrias.SetSize(0); int nt = GetNT(); for (i = 1; i <= nt; i++) { if (box1.Intersect (GetTriangle(i).box)) { btrias.Append (i); } } } } void STLTopology :: AddTriangle(const STLTriangle& t) { trias.Append(t); const Point<3> & p1 = GetPoint (t.PNum(1)); const Point<3> & p2 = GetPoint (t.PNum(2)); const Point<3> & p3 = GetPoint (t.PNum(3)); Box<3> box; box.Set (p1); box.Add (p2); box.Add (p3); /* // Point<3> pmin(p1), pmax(p1); pmin.SetToMin (p2); pmin.SetToMin (p3); pmax.SetToMax (p2); pmax.SetToMax (p3); */ trias.Last().box = box; trias.Last().center = Center (p1, p2, p3); double r1 = Dist (p1, trias.Last().center); double r2 = Dist (p2, trias.Last().center); double r3 = Dist (p3, trias.Last().center); trias.Last().rad = max2 (max2 (r1, r2), r3); if (geomsearchtreeon) {searchtree->Insert (box.PMin(), box.PMax(), trias.Size());} } int STLTopology :: GetLeftTrig(int p1, int p2) const { int i; for (i = 1; i <= trigsperpoint.EntrySize(p1); i++) { if (GetTriangle(trigsperpoint.Get(p1,i)).HasEdge(p1,p2)) {return trigsperpoint.Get(p1,i);} } PrintSysError("ERROR in GetLeftTrig !!!"); return 0; } int STLTopology :: GetRightTrig(int p1, int p2) const { return GetLeftTrig(p2,p1); } int STLTopology :: NeighbourTrigSorted(int trig, int edgenum) const { int i, p1, p2; int psearch = GetTriangle(trig).PNum(edgenum); for (i = 1; i <= 3; i++) { GetTriangle(trig).GetNeighbourPoints(GetTriangle(NeighbourTrig(trig,i)),p1,p2); if (p1 == psearch) {return NeighbourTrig(trig,i);} } PrintSysError("ERROR in NeighbourTrigSorted"); return 0; } int STLTopology :: GetTopEdgeNum (int pi1, int pi2) const { if (!ht_topedges) return 0; INDEX_2 i2(pi1, pi2); i2.Sort(); if (!ht_topedges->Used(i2)) return 0; return ht_topedges->Get(i2); } void STLTopology :: InvertTrig (int trig) { if (trig >= 1 && trig <= GetNT()) { GetTriangle(trig).ChangeOrientation(); FindNeighbourTrigs(); } else { PrintUserError("no triangle selected!"); } } void STLTopology :: DeleteTrig (int trig) { if (trig >= 1 && trig <= GetNT()) { trias.DeleteElement(trig); FindNeighbourTrigs(); } else { PrintUserError("no triangle selected!"); } } void STLTopology :: OrientAfterTrig (int trig) { int starttrig = trig; if (starttrig >= 1 && starttrig <= GetNT()) { Array oriented; oriented.SetSize(GetNT()); int i; for (i = 1; i <= oriented.Size(); i++) { oriented.Elem(i) = 0; } oriented.Elem(starttrig) = 1; int k; Array list1; list1.SetSize(0); Array list2; list2.SetSize(0); list1.Append(starttrig); int cnt = 1; int end = 0; int nt; while (!end) { end = 1; for (i = 1; i <= list1.Size(); i++) { const STLTriangle& tt = GetTriangle(list1.Get(i)); for (k = 1; k <= 3; k++) { nt = tt.NBTrigNum (k); // NeighbourTrig(list1.Get(i),k); if (oriented.Get(nt) == 0) { if (tt.IsWrongNeighbourFrom(GetTriangle(nt))) { GetTriangle(nt).ChangeOrientation(); } oriented.Elem(nt) = 1; list2.Append(nt); cnt++; end = 0; } } } list1.SetSize(0); for (i = 1; i <= list2.Size(); i++) { list1.Append(list2.Get(i)); } list2.SetSize(0); } PrintMessage(5,"NO corrected triangles = ",cnt); if (cnt == GetNT()) { PrintMessage(5,"ALL triangles oriented in same way!"); } else { PrintWarning("NOT ALL triangles oriented in same way!"); } // topedges.SetSize(0); FindNeighbourTrigs(); } else { PrintUserError("no triangle selected!"); } } } netgen-4.9.13/libsrc/stlgeom/Makefile.am0000644000175000001440000000047111240003503014757 00000000000000noinst_HEADERS = meshstlsurface.hpp stlgeom.hpp stlline.hpp \ stltool.hpp stltopology.hpp AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include METASOURCES = AUTO noinst_LTLIBRARIES = libstl.la libstl_la_SOURCES = meshstlsurface.cpp stlgeom.cpp stlgeomchart.cpp \ stlgeommesh.cpp stlline.cpp stltool.cpp stltopology.cpp netgen-4.9.13/libsrc/stlgeom/stlline.cpp0000644000175000001440000003465211240003503015111 00000000000000#include #include #include #include #include #include "stlgeom.hpp" namespace netgen { //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //++++++++++++++ EDGE DATA ++++++++++++++++++++++++++++++++++++++++++ //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ /* void STLEdgeData :: Write(ofstream& of) const { of // << angle << " " << p1 << " " << p2 << " " << lt << " " << rt << " " // << status << endl; } void STLEdgeData :: Read(ifstream& ifs) { // ifs >> angle; ifs >> p1; ifs >> p2; ifs >> lt; ifs >> rt; // ifs >> status; } int STLEdgeData :: GetStatus () const { if (topedgenr <= 0 || topedgenr > top->GetNTE()) return 0; return top->GetTopEdge (topedgenr).GetStatus(); } void STLEdgeData ::SetStatus (int stat) { if (topedgenr >= 1 && topedgenr <= top->GetNTE()) top->GetTopEdge (topedgenr).SetStatus(stat); } float STLEdgeData :: CosAngle() const { return top->GetTopEdge (topedgenr).CosAngle(); } void STLEdgeDataList :: ResetAll() { int i; for (i = 1; i <= edgedata.Size(); i++) { edgedata.Elem(i).SetUndefined(); } } void STLEdgeDataList :: ResetCandidates() { int i; for (i = 1; i <= edgedata.Size(); i++) { if (edgedata.Get(i).Candidate()) {edgedata.Elem(i).SetUndefined();} } } int STLEdgeDataList :: GetNConfEdges() const { int i; int cnt = 0; for (i = 1; i <= edgedata.Size(); i++) { if (edgedata.Get(i).Confirmed()) {cnt++;} } return cnt; } void STLEdgeDataList :: ConfirmCandidates() { int i; for (i = 1; i <= edgedata.Size(); i++) { if (edgedata.Get(i).Candidate()) {edgedata.Elem(i).SetConfirmed();} } } int STLEdgeDataList :: GetEdgeNum(int np1, int np2) const { INDEX_2 ed(np1,np2); ed.Sort(); if (hashtab.Used(ed)) { return hashtab.Get(ed); } // int i; // for (i = 1; i <= Size(); i++) // { // if ((Get(i).p1 == np1 && Get(i).p2 == np2) || // (Get(i).p2 == np1 && Get(i).p1 == np2)) // { // return i; // } // } return 0; } const STLEdgeDataList& STLEdgeDataList :: operator=(const STLEdgeDataList& edl) { int i; SetSize(edl.Size()); for (i = 1; i <= Size(); i++) { Add(edl.Get(i), i); } return *this; } void STLEdgeDataList :: Add(const STLEdgeData& ed, int i) { INDEX_2 edge(ed.p1,ed.p2); edge.Sort(); hashtab.Set(edge, i); Elem(i) = ed; AddEdgePP(ed.p1,i); AddEdgePP(ed.p2,i); } void STLEdgeDataList :: Write(ofstream& of) const { of.precision(16); int i; of << Size() << endl; for (i = 1; i <= Size(); i++) { Get(i).Write(of); } } void STLEdgeDataList :: Read(ifstream& ifs) { int i,n; ifs >> n; SetSize(n); STLEdgeData ed; for (i = 1; i <= n; i++) { ed.Read(ifs); Add(ed,i); } } int STLEdgeDataList :: GetNEPPStat(int p, int status) const { int i; int cnt = 0; for (i = 1; i <= GetNEPP(p); i++) { if (Get(GetEdgePP(p,i)).GetStatus() == status) { cnt++; } } return cnt; } int STLEdgeDataList :: GetNConfCandEPP(int p) const { int i; int cnt = 0; for (i = 1; i <= GetNEPP(p); i++) { if (Get(GetEdgePP(p,i)).ConfCand()) { cnt++; } } return cnt; } void STLEdgeDataList :: BuildLineWithEdge(int ep1, int ep2, Array& line) { int status = Get(GetEdgeNum(ep1,ep2)).GetStatus(); int found, pstart, p, en, pnew, ennew; int closed = 0; int j, i; for (j = 1; j <= 2; j++) { if (j == 1) {p = ep1;} if (j == 2) {p = ep2;} pstart = p; en = GetEdgeNum(ep1,ep2); found = 1; while (found && !closed) { found = 0; if (GetNEPPStat(p,status) == 2) { for (i = 1; i <= GetNEPP(p); i++) { const STLEdgeData& e = Get(GetEdgePP(p,i)); if (GetEdgePP(p,i) != en && e.GetStatus() == status) { if (e.p1 == p) {pnew = e.p2;} else {pnew = e.p1;} ennew = GetEdgePP(p,i); } } if (pnew == pstart) {closed = 1;} else { line.Append(twoint(p,pnew)); p = pnew; en = ennew; found = 1; } } } } } */ STLEdgeDataList :: STLEdgeDataList (STLTopology & ageom) : geom(ageom) { ; } STLEdgeDataList :: ~STLEdgeDataList() { ; } void STLEdgeDataList :: Store () { int i, ne = geom.GetNTE(); storedstatus.SetSize(ne); for (i = 1; i <= ne; i++) { storedstatus.Elem(i) = Get(i).GetStatus(); } } void STLEdgeDataList :: Restore () { int i, ne = geom.GetNTE(); if (storedstatus.Size() == ne) for (i = 1; i <= ne; i++) geom.GetTopEdge(i).SetStatus (storedstatus.Elem(i)); } void STLEdgeDataList :: ResetAll() { int i, ne = geom.GetNTE(); for (i = 1; i <= ne; i++) geom.GetTopEdge (i).SetStatus (ED_UNDEFINED); } int STLEdgeDataList :: GetNConfEdges() const { int i, ne = geom.GetNTE(); int cnt = 0; for (i = 1; i <= ne; i++) if (geom.GetTopEdge (i).GetStatus() == ED_CONFIRMED) cnt++; return cnt; } void STLEdgeDataList :: ChangeStatus(int status1, int status2) { int i, ne = geom.GetNTE(); for (i = 1; i <= ne; i++) if (geom.GetTopEdge (i).GetStatus() == status1) geom.GetTopEdge (i).SetStatus (status2); } /* void STLEdgeDataList :: Add(const STLEdgeData& ed, int i) { INDEX_2 edge(ed.p1,ed.p2); edge.Sort(); hashtab.Set(edge, i); Elem(i) = ed; AddEdgePP(ed.p1,i); AddEdgePP(ed.p2,i); } */ void STLEdgeDataList :: Write(ofstream& of) const { /* of.precision(16); int i; of << Size() << endl; for (i = 1; i <= Size(); i++) { Get(i).Write(of); } */ of.precision(16); int i, ne = geom.GetNTE(); //of << GetNConfEdges() << endl; of << geom.GetNTE() << endl; for (i = 1; i <= ne; i++) { const STLTopEdge & edge = geom.GetTopEdge(i); //if (edge.GetStatus() == ED_CONFIRMED) of << edge.GetStatus() << " "; const Point3d & p1 = geom.GetPoint (edge.PNum(1)); const Point3d & p2 = geom.GetPoint (edge.PNum(2)); of << p1.X() << " " << p1.Y() << " " << p1.Z() << " " << p2.X() << " " << p2.Y() << " " << p2.Z() << endl; } } void STLEdgeDataList :: Read(ifstream& ifs) { int i, nce; Point3d p1, p2; int pi1, pi2; int status, ednum; ifs >> nce; for (i = 1; i <= nce; i++) { ifs >> status; ifs >> p1.X() >> p1.Y() >> p1.Z(); ifs >> p2.X() >> p2.Y() >> p2.Z(); pi1 = geom.GetPointNum (p1); pi2 = geom.GetPointNum (p2); ednum = geom.GetTopEdgeNum (pi1, pi2); if (ednum) { geom.GetTopEdge(ednum).SetStatus (status); // geom.GetTopEdge (ednum).SetStatus (ED_CONFIRMED); } } /* int i,n; ifs >> n; SetSize(n); STLEdgeData ed; for (i = 1; i <= n; i++) { ed.Read(ifs); Add(ed,i); } */ } int STLEdgeDataList :: GetNEPPStat(int p, int status) const { int i; int cnt = 0; for (i = 1; i <= GetNEPP(p); i++) { if (Get(GetEdgePP(p,i)).GetStatus() == status) { cnt++; } } return cnt; } int STLEdgeDataList :: GetNConfCandEPP(int p) const { int i; int cnt = 0; for (i = 1; i <= GetNEPP(p); i++) { if (Get(GetEdgePP(p,i)).GetStatus() == ED_CANDIDATE || Get(GetEdgePP(p,i)).GetStatus() == ED_CONFIRMED) { cnt++; } } return cnt; } void STLEdgeDataList :: BuildLineWithEdge(int ep1, int ep2, Array& line) { int status = Get(GetEdgeNum(ep1,ep2)).GetStatus(); int found, pstart, p(0), en, pnew(0), ennew(0); int closed = 0; int j, i; for (j = 1; j <= 2; j++) { if (j == 1) {p = ep1;} if (j == 2) {p = ep2;} pstart = p; en = GetEdgeNum(ep1,ep2); found = 1; while (found && !closed) { found = 0; if (GetNEPPStat(p,status) == 2) { for (i = 1; i <= GetNEPP(p); i++) { const STLTopEdge & e = Get(GetEdgePP(p,i)); if (GetEdgePP(p,i) != en && e.GetStatus() == status) { if (e.PNum(1) == p) {pnew = e.PNum(2);} else {pnew = e.PNum(1);} ennew = GetEdgePP(p,i); } } if (pnew == pstart) {closed = 1;} else { line.Append(twoint(p,pnew)); p = pnew; en = ennew; found = 1; } } } } } int Exists(int p1, int p2, const Array& line) { int i; for (i = 1; i <= line.Size(); i++) { if (line.Get(i).i1 == p1 && line.Get(i).i2 == p2 || line.Get(i).i1 == p2 && line.Get(i).i2 == p1) {return 1;} } return 0; } void STLEdgeDataList :: BuildClusterWithEdge(int ep1, int ep2, Array& line) { int status = Get(GetEdgeNum(ep1,ep2)).GetStatus(); int p(0), en; int j, i, k; int oldend; int newend = 1; int pnew, ennew(0); int changed = 1; while (changed) { changed = 0; for (j = 1; j <= 2; j++) { oldend = newend; newend = line.Size(); for (k = oldend; k <= line.Size(); k++) { if (j == 1) p = line.Get(k).i1; if (j == 2) p = line.Get(k).i2; en = GetEdgeNum(line.Get(k).i1, line.Get(k).i2); for (i = 1; i <= GetNEPP(p); i++) { pnew = 0; const STLTopEdge & e = Get(GetEdgePP(p,i)); if (GetEdgePP(p,i) != en && e.GetStatus() == status) { if (e.PNum(1) == p) {pnew = e.PNum(2);} else {pnew = e.PNum(1);} ennew = GetEdgePP(p,i); } if (pnew && !Exists(p,pnew,line)) { changed = 1; line.Append(twoint(p,pnew)); p = pnew; en = ennew; } } } } } } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++ STL LINE +++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ STLLine :: STLLine(const STLGeometry * ageometry) : pts(), lefttrigs(), righttrigs() { geometry = ageometry; split = 0; }; int STLLine :: GetNS() const { if (pts.Size() <= 1) {return 0;} return pts.Size()-1; } void STLLine :: GetSeg(int nr, int& p1, int& p2) const { p1 = pts.Get(nr); p2 = pts.Get(nr+1); } int STLLine :: GetLeftTrig(int nr) const { if (nr > lefttrigs.Size()) {PrintSysError("In STLLine::GetLeftTrig!!!"); return 0;} return lefttrigs.Get(nr); }; int STLLine :: GetRightTrig(int nr) const { if (nr > righttrigs.Size()) {PrintSysError("In STLLine::GetRightTrig!!!"); return 0;} return righttrigs.Get(nr); }; double STLLine :: GetSegLen(const Array >& ap, int nr) const { return Dist(ap.Get(PNum(nr)),ap.Get(PNum(nr+1))); } double STLLine :: GetLength(const Array >& ap) const { double len = 0; for (int i = 2; i <= pts.Size(); i++) { len += (ap.Get(pts.Get(i)) - ap.Get(pts.Get(i-1))).Length(); } return len; } void STLLine :: GetBoundingBox (const Array > & ap, Box<3> & box) const { box.Set (ap.Get (pts[0])); for (int i = 1; i < pts.Size(); i++) box.Add (ap.Get(pts[i])); } Point<3> STLLine :: GetPointInDist(const Array >& ap, double dist, int& index) const { if (dist <= 0) { index = 1; return ap.Get(StartP()); } double len = 0; int i; for (i = 1; i < pts.Size(); i++) { double seglen = Dist (ap.Get(pts.Get(i)), ap.Get(pts.Get(i+1))); if (len + seglen > dist) { index = i; double relval = (dist - len) / (seglen + 1e-16); Vec3d v (ap.Get(pts.Get(i)), ap.Get(pts.Get(i+1))); return ap.Get(pts.Get(i)) + relval * v; } len += seglen; } index = pts.Size() - 1; return ap.Get(EndP()); } /* double stlgh; double GetH(const Point3d& p, double x) { return stlgh;//+0.5)*(x+0.5); } */ STLLine* STLLine :: Mesh(const Array >& ap, Array& mp, double ghi, class Mesh& mesh) const { STLLine* line = new STLLine(geometry); //stlgh = ghi; //uebergangsloesung!!!! double len = GetLength(ap); double inthl = 0; //integral of 1/h double dist = 0; double h; int ind; Point3d p; int i, j; Box<3> bbox; GetBoundingBox (ap, bbox); double diam = bbox.Diam(); double minh = mesh.LocalHFunction().GetMinH (bbox.PMin(), bbox.PMax()); double maxseglen = 0; for (i = 1; i <= GetNS(); i++) maxseglen = max2 (maxseglen, GetSegLen (ap, i)); int nph = 10+int(maxseglen / minh); //anzahl der integralauswertungen pro segment Array inthi(GetNS()*nph); Array curvelen(GetNS()*nph); for (i = 1; i <= GetNS(); i++) { //double seglen = GetSegLen(ap,i); for (j = 1; j <= nph; j++) { p = GetPointInDist(ap,dist,ind); //h = GetH(p,dist/len); h = mesh.GetH(p); dist += GetSegLen(ap,i)/(double)nph; inthl += GetSegLen(ap,i)/nph/(h); inthi.Elem((i-1)*nph+j) = GetSegLen(ap,i)/nph/h; curvelen.Elem((i-1)*nph+j) = GetSegLen(ap,i)/nph; } } int inthlint = int(inthl+1); if ( (inthlint < 3) && (StartP() == EndP())) { inthlint = 3; } if ( (inthlint == 1) && ShouldSplit()) { inthlint = 2; } double fact = inthl/(double)inthlint; dist = 0; j = 1; p = ap.Get(StartP()); int pn = AddPointIfNotExists(mp, p, 1e-10*diam); int segn = 1; line->AddPoint(pn); line->AddLeftTrig(GetLeftTrig(segn)); line->AddRightTrig(GetRightTrig(segn)); line->AddDist(dist); inthl = 0; //restart each meshseg for (i = 1; i <= inthlint; i++) { while (inthl < 1.000000001 && j <= inthi.Size()) // while (inthl-1. < 1e-9) && j <= inthi.Size()) { inthl += inthi.Get(j)/fact; dist += curvelen.Get(j); j++; } //went to far: j--; double tofar = (inthl - 1)/inthi.Get(j); inthl -= tofar*inthi.Get(j); dist -= tofar*curvelen.Get(j)*fact; if (i == inthlint && fabs(dist - len) >= 1E-8) { PrintSysError("meshline failed!!!"); } if (i != inthlint) { p = GetPointInDist(ap,dist,ind); pn = AddPointIfNotExists(mp, p, 1e-10*diam); segn = ind; line->AddPoint(pn); line->AddLeftTrig(GetLeftTrig(segn)); line->AddRightTrig(GetRightTrig(segn)); line->AddDist(dist); } inthl = tofar*inthi.Get(j); dist += tofar*curvelen.Get(j)*fact; j++; } p = ap.Get(EndP()); pn = AddPointIfNotExists(mp, p, 1e-10*diam); segn = GetNS(); line->AddPoint(pn); line->AddLeftTrig(GetLeftTrig(segn)); line->AddRightTrig(GetRightTrig(segn)); line->AddDist(dist); for (int ii = 1; ii <= line->GetNS(); ii++) { int p1, p2; line->GetSeg(ii,p1,p2); } /* (*testout) << "line, " << ap.Get(StartP()) << "-" << ap.Get(EndP()) << " len = " << Dist (ap.Get(StartP()), ap.Get(EndP())) << endl; */ return line; } } netgen-4.9.13/libsrc/stlgeom/meshstlsurface.cpp0000644000175000001440000006246011240003503016465 00000000000000#include #include #include #include #include #include "stlgeom.hpp" namespace netgen { static void STLFindEdges (STLGeometry & geom, class Mesh & mesh) { int i, j; double h; h = mparam.maxh; // mark edge points: //int ngp = geom.GetNP(); geom.RestrictLocalH(mesh, h); PushStatusF("Mesh Lines"); Array meshlines; Array meshpoints; PrintMessage(3,"Mesh Lines"); for (i = 1; i <= geom.GetNLines(); i++) { meshlines.Append(geom.GetLine(i)->Mesh(geom.GetPoints(), meshpoints, h, mesh)); SetThreadPercent(100.0 * (double)i/(double)geom.GetNLines()); } geom.meshpoints.SetSize(0); //testing geom.meshlines.SetSize(0); //testing int pim; for (i = 1; i <= meshpoints.Size(); i++) { geom.meshpoints.Append(meshpoints.Get(i)); //testing pim = mesh.AddPoint(meshpoints.Get(i)); } //(++++++++++++++testing for (i = 1; i <= geom.GetNLines(); i++) { geom.meshlines.Append(meshlines.Get(i)); } //++++++++++++++testing) PrintMessage(7,"feed with edges"); for (i = 1; i <= meshlines.Size(); i++) { STLLine* line = meshlines.Get(i); (*testout) << "store line " << i << endl; for (j = 1; j <= line->GetNS(); j++) { int p1, p2; line->GetSeg(j, p1, p2); int trig1, trig2, trig1b, trig2b; if (p1 == p2) cout << "Add Segment, p1 == p2 == " << p1 << endl; // Test auf geschlossener Rand mit 2 Segmenten if ((j == 2) && (line->GetNS() == 2)) { int oldp1, oldp2; line->GetSeg (1, oldp1, oldp2); if (oldp1 == p2 && oldp2 == p1) { PrintMessage(7,"MESSAGE: don't use second segment"); continue; } } //mesh point number //p1 = geom2meshnum.Get(p1); // for unmeshed lines!!! //p2 = geom2meshnum.Get(p2); // for unmeshed lines!!! //left and right trigs trig1 = line->GetLeftTrig(j); trig2 = line->GetRightTrig(j); trig1b = line->GetLeftTrig(j+1); trig2b = line->GetRightTrig(j+1); (*testout) << "j = " << j << ", p1 = " << p1 << ", p2 = " << p2 << endl; (*testout) << "segm-trigs: " << "trig1 = " << trig1 << ", trig1b = " << trig1b << ", trig2 = " << trig2 << ", trig2b = " << trig2b << endl; if (trig1 <= 0 || trig2 <= 0 || trig1b <= 0 || trig2b <= 0) { cout << "negative trigs, " << ", trig1 = " << trig1 << ", trig1b = " << trig1b << ", trig2 = " << trig2 << ", trig2b = " << trig2b << endl; } /* (*testout) << " trigs p1: " << trig1 << " - " << trig2 << endl; (*testout) << " trigs p2: " << trig1b << " - " << trig2b << endl; (*testout) << " charts p1: " << geom.GetChartNr(trig1) << " - " << geom.GetChartNr(trig2) << endl; (*testout) << " charts p2: " << geom.GetChartNr(trig1b) << " - " << geom.GetChartNr(trig2b) << endl; */ Point3d hp, hp2; Segment seg; seg[0] = p1; seg[1] = p2; seg.si = geom.GetTriangle(trig1).GetFaceNum(); seg.edgenr = i; seg.epgeominfo[0].edgenr = i; seg.epgeominfo[0].dist = line->GetDist(j); seg.epgeominfo[1].edgenr = i; seg.epgeominfo[1].dist = line->GetDist(j+1); /* (*testout) << "seg = " << "edgenr " << seg.epgeominfo[0].edgenr << " dist " << seg.epgeominfo[0].dist << " edgenr " << seg.epgeominfo[1].edgenr << " dist " << seg.epgeominfo[1].dist << endl; */ seg.geominfo[0].trignum = trig1; seg.geominfo[1].trignum = trig1b; /* geom.SelectChartOfTriangle (trig1); hp = hp2 = mesh.Point (seg[0]); seg.geominfo[0].trignum = geom.Project (hp); (*testout) << "hp = " << hp2 << ", hp proj = " << hp << ", trignum = " << seg.geominfo[0].trignum << endl; if (Dist (hp, hp2) > 1e-5 || seg.geominfo[0].trignum == 0) { (*testout) << "PROBLEM" << endl; } geom.SelectChartOfTriangle (trig1b); hp = hp2 = mesh.Point (seg[1]); seg.geominfo[1].trignum = geom.Project (hp); (*testout) << "hp = " << hp2 << ", hp proj = " << hp << ", trignum = " << seg.geominfo[1].trignum << endl; if (Dist (hp, hp2) > 1e-5 || seg.geominfo[1].trignum == 0) { (*testout) << "PROBLEM" << endl; } */ if (Dist (mesh.Point(seg[0]), mesh.Point(seg[1])) < 1e-10) { (*testout) << "ERROR: Line segment of length 0" << endl; (*testout) << "pi1, 2 = " << seg[0] << ", " << seg[1] << endl; (*testout) << "p1, 2 = " << mesh.Point(seg[0]) << ", " << mesh.Point(seg[1]) << endl; throw NgException ("Line segment of length 0"); } mesh.AddSegment (seg); Segment seg2; seg2[0] = p2; seg2[1] = p1; seg2.si = geom.GetTriangle(trig2).GetFaceNum(); seg2.edgenr = i; seg2.epgeominfo[0].edgenr = i; seg2.epgeominfo[0].dist = line->GetDist(j+1); seg2.epgeominfo[1].edgenr = i; seg2.epgeominfo[1].dist = line->GetDist(j); /* (*testout) << "seg = " << "edgenr " << seg2.epgeominfo[0].edgenr << " dist " << seg2.epgeominfo[0].dist << " edgenr " << seg2.epgeominfo[1].edgenr << " dist " << seg2.epgeominfo[1].dist << endl; */ seg2.geominfo[0].trignum = trig2b; seg2.geominfo[1].trignum = trig2; /* geom.SelectChartOfTriangle (trig2); hp = hp2 = mesh.Point (seg[0]); seg2.geominfo[0].trignum = geom.Project (hp); (*testout) << "hp = " << hp2 << ", hp proj = " << hp << ", trignum = " << seg.geominfo[0].trignum << endl; if (Dist (hp, hp2) > 1e-5 || seg2.geominfo[0].trignum == 0) { (*testout) << "Get GeomInfo PROBLEM" << endl; } geom.SelectChartOfTriangle (trig2b); hp = hp2 = mesh.Point (seg[1]); seg2.geominfo[1].trignum = geom.Project (hp); (*testout) << "hp = " << hp2 << ", hp proj = " << hp << ", trignum = " << seg.geominfo[1].trignum << endl; if (Dist (hp, hp2) > 1e-5 || seg2.geominfo[1].trignum == 0) { (*testout) << "Get GeomInfo PROBLEM" << endl; } */ mesh.AddSegment (seg2); /* // should be start triangle and end triangle int bothtrigs1[2] = { trig1, trig1 }; meshing.AddBoundaryElement (p1, p2, sizeof (bothtrigs1), &bothtrigs1); int bothtrigs2[2] = { trig2, trig2 }; meshing.AddBoundaryElement (p2, p1, sizeof (bothtrigs2), &bothtrigs2); */ } } PopStatus(); } void STLSurfaceMeshing1 (STLGeometry & geom, class Mesh & mesh, int retrynr); int STLSurfaceMeshing (STLGeometry & geom, class Mesh & mesh) { int i, j; PrintFnStart("Do Surface Meshing"); geom.PrepareSurfaceMeshing(); if (mesh.GetNSeg() == 0) STLFindEdges (geom, mesh); int nopen; int outercnt = 20; // mesh.Save ("mesh.edges"); for (i = 1; i <= mesh.GetNSeg(); i++) { const Segment & seg = mesh.LineSegment (i); if (seg.geominfo[0].trignum <= 0 || seg.geominfo[1].trignum <= 0) { (*testout) << "Problem with segment " << i << ": " << seg << endl; } } do { outercnt--; if (outercnt <= 0) return MESHING3_OUTERSTEPSEXCEEDED; if (multithread.terminate) { return MESHING3_TERMINATE; } mesh.FindOpenSegments(); nopen = mesh.GetNOpenSegments(); if (nopen) { int trialcnt = 0; while (nopen && trialcnt <= 5) { if (multithread.terminate) { return MESHING3_TERMINATE; } trialcnt++; STLSurfaceMeshing1 (geom, mesh, trialcnt); mesh.FindOpenSegments(); nopen = mesh.GetNOpenSegments(); if (nopen) { geom.ClearMarkedSegs(); for (i = 1; i <= nopen; i++) { const Segment & seg = mesh.GetOpenSegment (i); geom.AddMarkedSeg(mesh.Point(seg[0]),mesh.Point(seg[1])); } geom.InitMarkedTrigs(); for (i = 1; i <= nopen; i++) { const Segment & seg = mesh.GetOpenSegment (i); geom.SetMarkedTrig(seg.geominfo[0].trignum,1); geom.SetMarkedTrig(seg.geominfo[1].trignum,1); } MeshOptimizeSTLSurface optmesh(geom); optmesh.SetFaceIndex (0); optmesh.SetImproveEdges (0); optmesh.SetMetricWeight (0); mesh.CalcSurfacesOfNode(); optmesh.EdgeSwapping (mesh, 0); mesh.CalcSurfacesOfNode(); optmesh.ImproveMesh (mesh); } mesh.Compress(); mesh.FindOpenSegments(); nopen = mesh.GetNOpenSegments(); if (trialcnt <= 5 && nopen) { mesh.RemoveOneLayerSurfaceElements(); if (trialcnt >= 4) { mesh.FindOpenSegments(); mesh.RemoveOneLayerSurfaceElements(); mesh.FindOpenSegments (); nopen = mesh.GetNOpenSegments(); } } } if (multithread.terminate) return MESHING3_TERMINATE; if (nopen) { PrintMessage(3,"Meshing failed, trying to refine"); mesh.FindOpenSegments (); nopen = mesh.GetNOpenSegments(); mesh.FindOpenSegments (); mesh.RemoveOneLayerSurfaceElements(); mesh.FindOpenSegments (); mesh.RemoveOneLayerSurfaceElements(); // Open edge-segments will be refined ! INDEX_2_HASHTABLE openseght (nopen+1); for (i = 1; i <= mesh.GetNOpenSegments(); i++) { const Segment & seg = mesh.GetOpenSegment (i); INDEX_2 i2(seg[0], seg[1]); i2.Sort(); openseght.Set (i2, 1); } mesh.FindOpenSegments (); mesh.RemoveOneLayerSurfaceElements(); mesh.FindOpenSegments (); mesh.RemoveOneLayerSurfaceElements(); INDEX_2_HASHTABLE newpht(100); int nsegold = mesh.GetNSeg(); for (i = 1; i <= nsegold; i++) { Segment seg = mesh.LineSegment(i); INDEX_2 i2(seg[0], seg[1]); i2.Sort(); if (openseght.Used (i2)) { // segment will be split PrintMessage(7,"Split segment ", int(seg[0]), "-", int(seg[1])); Segment nseg1, nseg2; EdgePointGeomInfo newgi; const EdgePointGeomInfo & gi1 = seg.epgeominfo[0]; const EdgePointGeomInfo & gi2 = seg.epgeominfo[1]; newgi.dist = 0.5 * (gi1.dist + gi2.dist); newgi.edgenr = gi1.edgenr; int hi; Point3d newp; int newpi; if (!newpht.Used (i2)) { newp = geom.GetLine (gi1.edgenr)-> GetPointInDist (geom.GetPoints(), newgi.dist, hi); newpi = mesh.AddPoint (newp); newpht.Set (i2, newpi); } else { newpi = newpht.Get (i2); newp = mesh.Point (newpi); } nseg1 = seg; nseg2 = seg; nseg1[1] = newpi; nseg1.epgeominfo[1] = newgi; nseg2[0] = newpi; nseg2.epgeominfo[0] = newgi; mesh.LineSegment(i) = nseg1; mesh.AddSegment (nseg2); mesh.RestrictLocalH (Center (mesh.Point(nseg1[0]), mesh.Point(nseg1[1])), Dist (mesh.Point(nseg1[0]), mesh.Point(nseg1[1]))); mesh.RestrictLocalH (Center (mesh.Point(nseg2[0]), mesh.Point(nseg2[1])), Dist (mesh.Point(nseg2[0]), mesh.Point(nseg2[1]))); } } } nopen = -1; } else { PrintMessage(5,"mesh is closed, verifying ..."); // no open elements, check wrong elemetns (intersecting..) PrintMessage(5,"check overlapping"); // mesh.FindOpenElements(); // would leed to locked points if(mesh.CheckOverlappingBoundary()) { return MESHING3_BADSURFACEMESH; } geom.InitMarkedTrigs(); for (i = 1; i <= mesh.GetNSE(); i++) if (mesh.SurfaceElement(i).BadElement()) { int trig = mesh.SurfaceElement(i).PNum(1); geom.SetMarkedTrig(trig,1); PrintMessage(7, "overlapping element, will be removed"); } Array refpts; Array refh; // was commented: for (i = 1; i <= mesh.GetNSE(); i++) if (mesh.SurfaceElement(i).BadElement()) { for (j = 1; j <= 3; j++) { refpts.Append (mesh.Point (mesh.SurfaceElement(i).PNum(j))); refh.Append (mesh.GetH (refpts.Last()) / 2); } mesh.DeleteSurfaceElement(i); } // delete wrong oriented element for (i = 1; i <= mesh.GetNSE(); i++) { const Element2d & el = mesh.SurfaceElement(i); if (!el.PNum(1)) continue; Vec3d n = Cross (Vec3d (mesh.Point(el.PNum(1)), mesh.Point(el.PNum(2))), Vec3d (mesh.Point(el.PNum(1)), mesh.Point(el.PNum(3)))); Vec3d ng = geom.GetTriangle(el.GeomInfoPi(1).trignum).Normal(); if (n * ng < 0) { refpts.Append (mesh.Point (mesh.SurfaceElement(i).PNum(1))); refh.Append (mesh.GetH (refpts.Last()) / 2); mesh.DeleteSurfaceElement(i); } } // end comments for (i = 1; i <= refpts.Size(); i++) mesh.RestrictLocalH (refpts.Get(i), refh.Get(i)); mesh.RemoveOneLayerSurfaceElements(); mesh.Compress(); mesh.FindOpenSegments (); nopen = mesh.GetNOpenSegments(); /* if (!nopen) { // mesh is still ok void STLSurfaceOptimization (STLGeometry & geom, class Mesh & mesh, MeshingParameters & mparam) } */ } } while (nopen); mesh.Compress(); mesh.CalcSurfacesOfNode(); return MESHING3_OK; } void STLSurfaceMeshing1 (STLGeometry & geom, class Mesh & mesh, int retrynr) { int i, j; double h; h = mparam.maxh; mesh.FindOpenSegments(); Array spiralps(0); spiralps.SetSize(0); for (i = 1; i <= geom.GetNP(); i++) { if (geom.GetSpiralPoint(i)) {spiralps.Append(i);} } PrintMessage(7,"NO spiralpoints = ", spiralps.Size()); //int spfound; int sppointnum; int spcnt = 0; Array meshsp(mesh.GetNP()); for (i = 1; i <= mesh.GetNP(); i++) { meshsp.Elem(i) = 0; for (j = 1; j <= spiralps.Size(); j++) if (Dist2(geom.GetPoint(spiralps.Get(j)), mesh.Point(i)) < 1e-20) meshsp.Elem(i) = spiralps.Get(j); } Array opensegsperface(mesh.GetNFD()); for (i = 1; i <= mesh.GetNFD(); i++) opensegsperface.Elem(i) = 0; for (i = 1; i <= mesh.GetNOpenSegments(); i++) { int si = mesh.GetOpenSegment (i).si; if (si >= 1 && si <= mesh.GetNFD()) { opensegsperface.Elem(si)++; } else { cerr << "illegal face index" << endl; } } double starttime = GetTime (); for (int fnr = 1; fnr <= mesh.GetNFD(); fnr++) if (opensegsperface.Get(fnr)) { if (multithread.terminate) return; PrintMessage(5,"Meshing surface ", fnr, "/", mesh.GetNFD()); MeshingSTLSurface meshing (geom); meshing.SetStartTime (starttime); for (i = 1; i <= mesh.GetNP(); i++) { /* spfound = 0; for (j = 1; j <= spiralps.Size(); j++) { if (Dist2(geom.GetPoint(spiralps.Get(j)),mesh.Point(i)) < 1e-20) {spfound = 1; sppointnum = spiralps.Get(j);} } */ sppointnum = 0; if (i <= meshsp.Size()) sppointnum = meshsp.Get(i); //spfound = 0; if (sppointnum) { MultiPointGeomInfo mgi; int ntrigs = geom.NOTrigsPerPoint(sppointnum); spcnt++; for (j = 0; j < ntrigs; j++) { PointGeomInfo gi; gi.trignum = geom.TrigPerPoint(sppointnum, j+1); mgi.AddPointGeomInfo (gi); } // Einfuegen von ConePoint: Point bekommt alle // Dreiecke (werden dann intern kopiert) // Ein Segment zum ConePoint muss vorhanden sein !!! meshing.AddPoint (mesh.Point(i), i, &mgi); } else { meshing.AddPoint (mesh.Point(i), i); } } for (i = 1; i <= mesh.GetNOpenSegments(); i++) { const Segment & seg = mesh.GetOpenSegment (i); if (seg.si == fnr) meshing.AddBoundaryElement (seg[0], seg[1], seg.geominfo[0], seg.geominfo[1]); } PrintMessage(3,"start meshing, trialcnt = ", retrynr); /* (*testout) << "start meshing with h = " << h << endl; */ meshing.GenerateMesh (mesh, h, fnr); // face index extern void Render(); Render(); } mesh.CalcSurfacesOfNode(); } void STLSurfaceOptimization (STLGeometry & geom, class Mesh & mesh, MeshingParameters & meshparam) { PrintFnStart("optimize STL Surface"); MeshOptimizeSTLSurface optmesh(geom); // int i; /* for (i = 1; i <= mparam.optsteps2d; i++) { EdgeSwapping (mesh, 1, 1); CombineImprove (mesh, 1); optmesh.ImproveMesh (mesh, 0, 10, 1, 1); } */ optmesh.SetFaceIndex (0); optmesh.SetImproveEdges (0); optmesh.SetMetricWeight (meshparam.elsizeweight); PrintMessage(5,"optimize string = ", meshparam.optimize2d, " elsizew = ", meshparam.elsizeweight); for (i = 1; i <= meshparam.optsteps2d; i++) for (size_t j = 1; j <= strlen(meshparam.optimize2d); j++) { if (multithread.terminate) break; //(*testout) << "optimize, before, step = " << meshparam.optimize2d[j-1] << mesh.Point (3679) << endl; mesh.CalcSurfacesOfNode(); switch (meshparam.optimize2d[j-1]) { case 's': { optmesh.EdgeSwapping (mesh, 0); break; } case 'S': { optmesh.EdgeSwapping (mesh, 1); break; } case 'm': { optmesh.ImproveMesh(mesh); break; } case 'c': { optmesh.CombineImprove (mesh); break; } } //(*testout) << "optimize, after, step = " << meshparam.optimize2d[j-1] << mesh.Point (3679) << endl; } geom.surfaceoptimized = 1; mesh.Compress(); mesh.CalcSurfacesOfNode(); } MeshingSTLSurface :: MeshingSTLSurface (STLGeometry & ageom) : Meshing2(ageom.GetBoundingBox()), geom(ageom) { ; } void MeshingSTLSurface :: DefineTransformation (const Point3d & p1, const Point3d & p2, const PointGeomInfo * geominfo, const PointGeomInfo * geominfo2) { transformationtrig = geominfo[0].trignum; geom.DefineTangentialPlane(p1, p2, transformationtrig); } void MeshingSTLSurface :: TransformToPlain (const Point3d & locpoint, const MultiPointGeomInfo & gi, Point2d & plainpoint, double h, int & zone) { int trigs[10000]; int i; if (gi.GetNPGI() >= 9999) { PrintError("In Transform to plane: increase size of trigs!!!"); } for (i = 1; i <= gi.GetNPGI(); i++) trigs[i-1] = gi.GetPGI(i).trignum; trigs[gi.GetNPGI()] = 0; // int trig = gi.trignum; // (*testout) << "locpoint = " << locpoint; Point<2> hp2d; geom.ToPlane (locpoint, trigs, hp2d, h, zone, 1); plainpoint = hp2d; // geom.ToPlane (locpoint, NULL, plainpoint, h, zone, 1); /* (*testout) << " plainpoint = " << plainpoint << " h = " << h << endl; */ } /* int MeshingSTLSurface :: ComputeLineGeoInfo (const Point3d & p1, const Point3d & p2, int & geoinfosize, void *& geoinfo) { static int geomtrig[2] = { 0, 0 }; Point3d hp; hp = p1; geomtrig[0] = geom.Project (hp); hp = p2; geomtrig[1] = geom.Project (hp); geoinfosize = sizeof (geomtrig); geoinfo = &geomtrig; if (geomtrig[0] == 0) { return 1; } return 0; } */ int MeshingSTLSurface :: ComputePointGeomInfo (const Point3d & p, PointGeomInfo & gi) { // compute triangle of point, // if non-unique: 0 Point<3> hp = p; gi.trignum = geom.Project (hp); if (!gi.trignum) { return 1; } return 0; } int MeshingSTLSurface :: ChooseChartPointGeomInfo (const MultiPointGeomInfo & mpgi, PointGeomInfo & pgi) { int i; for (i = 1; i <= mpgi.GetNPGI(); i++) if (geom.TrigIsInOC (mpgi.GetPGI(i).trignum, geom.meshchart)) { pgi = mpgi.GetPGI(i); return 0; } /* for (i = 0; i < mpgi.cnt; i++) { // (*testout) << "d" << endl; if (geom.TrigIsInOC (mpgi.mgi[i].trignum, geom.meshchart)) { pgi = mpgi.mgi[i]; return 0; } } */ PrintMessage(7,"INFORM: no gi on chart"); pgi.trignum = 1; return 1; } int MeshingSTLSurface :: IsLineVertexOnChart (const Point3d & p1, const Point3d & p2, int endpoint, const PointGeomInfo & gi) { Vec3d baselinenormal = geom.meshtrignv; int lineendtrig = gi.trignum; return geom.TrigIsInOC (lineendtrig, geom.meshchart); // Vec3d linenormal = geom.GetTriangleNormal (lineendtrig); // return ( (baselinenormal * linenormal) > cos (30 * (M_PI/180)) ); } void MeshingSTLSurface :: GetChartBoundary (Array & points, Array & points3d, Array & lines, double h) const { points.SetSize (0); points3d.SetSize (0); lines.SetSize (0); geom.GetMeshChartBoundary (points, points3d, lines, h); } int MeshingSTLSurface :: TransformFromPlain (Point2d & plainpoint, Point3d & locpoint, PointGeomInfo & gi, double h) { //return 0, wenn alles OK Point<3> hp3d; int res = geom.FromPlane (plainpoint, hp3d, h); locpoint = hp3d; ComputePointGeomInfo (locpoint, gi); return res; } int MeshingSTLSurface :: BelongsToActiveChart (const Point3d & p, const PointGeomInfo & gi) { return (geom.TrigIsInOC(gi.trignum, geom.meshchart) != 0); } double MeshingSTLSurface :: CalcLocalH (const Point3d & p, double gh) const { return gh; } double MeshingSTLSurface :: Area () const { return geom.Area(); } MeshOptimizeSTLSurface :: MeshOptimizeSTLSurface (STLGeometry & ageom) : MeshOptimize2d(), geom(ageom) { ; } void MeshOptimizeSTLSurface :: SelectSurfaceOfPoint (const Point<3> & p, const PointGeomInfo & gi) { // (*testout) << "sel char: " << gi.trignum << endl; geom.SelectChartOfTriangle (gi.trignum); // geom.SelectChartOfPoint (p); } void MeshOptimizeSTLSurface :: ProjectPoint (INDEX surfind, Point<3> & p) const { if (!geom.Project (p)) { PrintMessage(7,"project failed"); if (!geom.ProjectOnWholeSurface(p)) { PrintMessage(7, "project on whole surface failed"); } } // geometry.GetSurface(surfind)->Project (p); } void MeshOptimizeSTLSurface :: ProjectPoint2 (INDEX surfind, INDEX surfind2, Point<3> & p) const { /* ProjectToEdge ( geometry.GetSurface(surfind), geometry.GetSurface(surfind2), p); */ } int MeshOptimizeSTLSurface :: CalcPointGeomInfo(PointGeomInfo& gi, const Point<3> & p3) const { Point<3> hp = p3; gi.trignum = geom.Project (hp); if (gi.trignum) { return 1; } return 0; } void MeshOptimizeSTLSurface :: GetNormalVector(INDEX surfind, const Point<3> & p, Vec<3> & n) const { n = geom.GetChartNormalVector(); /* geometry.GetSurface(surfind)->CalcGradient (p, n); n /= n.Length(); if (geometry.GetSurface(surfind)->Inverse()) n *= -1; */ } RefinementSTLGeometry :: RefinementSTLGeometry (const STLGeometry & ageom) : Refinement(), geom(ageom) { ; } RefinementSTLGeometry :: ~RefinementSTLGeometry () { ; } void RefinementSTLGeometry :: PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint, int surfi, const PointGeomInfo & gi1, const PointGeomInfo & gi2, Point<3> & newp, PointGeomInfo & newgi) { newp = p1+secpoint*(p2-p1); /* (*testout) << "surf-between: p1 = " << p1 << ", p2 = " << p2 << ", gi = " << gi1 << " - " << gi2 << endl; */ if (gi1.trignum > 0) { // ((STLGeometry&)geom).SelectChartOfTriangle (gi1.trignum); Point<3> np1 = newp; Point<3> np2 = newp; ((STLGeometry&)geom).SelectChartOfTriangle (gi1.trignum); int tn1 = geom.Project (np1); ((STLGeometry&)geom).SelectChartOfTriangle (gi2.trignum); int tn2 = geom.Project (np2); newgi.trignum = tn1; //urspruengliche version newp = np1; //urspruengliche version if (!newgi.trignum) { newgi.trignum = tn2; newp = np2; } if (!newgi.trignum) newgi.trignum = gi1.trignum; /* if (tn1 != 0 && tn2 != 0 && ((STLGeometry&)geom).GetAngle(tn1,tn2) < M_PI*0.05) { newgi.trignum = tn1; newp = np1; } else { newp = ((STLGeometry&)geom).PointBetween(p1, gi1.trignum, p2, gi2.trignum); tn1 = ((STLGeometry&)geom).Project(newp); newgi.trignum = tn1; if (!tn1) { newp = Center (p1, p2); newgi.trignum = 0; } } */ } else { // (*testout) << "WARNING: PointBetween got geominfo = 0" << endl; newp = p1+secpoint*(p2-p1); newgi.trignum = 0; } // (*testout) << "newp = " << newp << ", ngi = " << newgi << endl; } void RefinementSTLGeometry :: PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint, int surfi1, int surfi2, const EdgePointGeomInfo & gi1, const EdgePointGeomInfo & gi2, Point<3> & newp, EdgePointGeomInfo & newgi) { /* (*testout) << "edge-between: p1 = " << p1 << ", p2 = " << p2 << ", gi1,2 = " << gi1 << ", " << gi2 << endl; */ /* newp = Center (p1, p2); ((STLGeometry&)geom).SelectChartOfTriangle (gi1.trignum); newgi.trignum = geom.Project (newp); */ int hi; newgi.dist = (1.0-secpoint) * gi1.dist + secpoint*gi2.dist; newgi.edgenr = gi1.edgenr; /* (*testout) << "p1 = " << p1 << ", p2 = " << p2 << endl; (*testout) << "refedge: " << gi1.edgenr << " d1 = " << gi1.dist << ", d2 = " << gi2.dist << endl; */ newp = geom.GetLine (gi1.edgenr)->GetPointInDist (geom.GetPoints(), newgi.dist, hi); // (*testout) << "newp = " << newp << endl; } void RefinementSTLGeometry :: ProjectToSurface (Point<3> & p, int surfi) { cout << "RefinementSTLGeometry :: ProjectToSurface not implemented!" << endl; }; void RefinementSTLGeometry :: ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi) { ((STLGeometry&)geom).SelectChartOfTriangle (gi.trignum); gi.trignum = geom.Project (p); // if (!gi.trignum) // cout << "projectSTL failed" << endl; }; } netgen-4.9.13/libsrc/stlgeom/Makefile.in0000644000175000001440000003663011375342730015017 00000000000000# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = libsrc/stlgeom DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/tcl.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libstl_la_LIBADD = am_libstl_la_OBJECTS = meshstlsurface.lo stlgeom.lo stlgeomchart.lo \ stlgeommesh.lo stlline.lo stltool.lo stltopology.lo libstl_la_OBJECTS = $(am_libstl_la_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libstl_la_SOURCES) DIST_SOURCES = $(libstl_la_SOURCES) HEADERS = $(noinst_HEADERS) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH = @CYGPATH@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FFMPEG_INCLUDES = @FFMPEG_INCLUDES@ FFMPEG_LIBS = @FFMPEG_LIBS@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ JPEGLIB_INCLUDES = @JPEGLIB_INCLUDES@ JPEGLIB_LIBS = @JPEGLIB_LIBS@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBGLU = @LIBGLU@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MPI_INCLUDES = @MPI_INCLUDES@ MPI_LIBS = @MPI_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OCCFLAGS = @OCCFLAGS@ OCCLIBS = @OCCLIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CFLAGS = @PKG_CFLAGS@ PKG_HEADERS = @PKG_HEADERS@ PKG_INCLUDES = @PKG_INCLUDES@ PKG_LIBS = @PKG_LIBS@ PKG_LIB_FILE = @PKG_LIB_FILE@ PKG_STUB_LIB_FILE = @PKG_STUB_LIB_FILE@ PKG_STUB_OBJECTS = @PKG_STUB_OBJECTS@ PKG_STUB_SOURCES = @PKG_STUB_SOURCES@ PKG_TCL_SOURCES = @PKG_TCL_SOURCES@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ TCL_BIN_DIR = @TCL_BIN_DIR@ TCL_DEFS = @TCL_DEFS@ TCL_EXTRA_CFLAGS = @TCL_EXTRA_CFLAGS@ TCL_INCLUDES = @TCL_INCLUDES@ TCL_LD_FLAGS = @TCL_LD_FLAGS@ TCL_LIBS = @TCL_LIBS@ TCL_LIB_FILE = @TCL_LIB_FILE@ TCL_LIB_FLAG = @TCL_LIB_FLAG@ TCL_LIB_SPEC = @TCL_LIB_SPEC@ TCL_SHLIB_LD_LIBS = @TCL_SHLIB_LD_LIBS@ TCL_SRC_DIR = @TCL_SRC_DIR@ TCL_STUB_LIB_FILE = @TCL_STUB_LIB_FILE@ TCL_STUB_LIB_FLAG = @TCL_STUB_LIB_FLAG@ TCL_STUB_LIB_SPEC = @TCL_STUB_LIB_SPEC@ TCL_VERSION = @TCL_VERSION@ TK_BIN_DIR = @TK_BIN_DIR@ TK_LIBS = @TK_LIBS@ TK_LIB_FILE = @TK_LIB_FILE@ TK_LIB_FLAG = @TK_LIB_FLAG@ TK_LIB_SPEC = @TK_LIB_SPEC@ TK_SRC_DIR = @TK_SRC_DIR@ TK_STUB_LIB_FILE = @TK_STUB_LIB_FILE@ TK_STUB_LIB_FLAG = @TK_STUB_LIB_FLAG@ TK_STUB_LIB_SPEC = @TK_STUB_LIB_SPEC@ TK_VERSION = @TK_VERSION@ TK_XINCLUDES = @TK_XINCLUDES@ TOGLLIBDIR = @TOGLLIBDIR@ TOGL_WINDOWINGSYSTEM = @TOGL_WINDOWINGSYSTEM@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_HEADERS = meshstlsurface.hpp stlgeom.hpp stlline.hpp \ stltool.hpp stltopology.hpp AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include METASOURCES = AUTO noinst_LTLIBRARIES = libstl.la libstl_la_SOURCES = meshstlsurface.cpp stlgeom.cpp stlgeomchart.cpp \ stlgeommesh.cpp stlline.cpp stltool.cpp stltopology.cpp all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libsrc/stlgeom/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --foreign libsrc/stlgeom/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libstl.la: $(libstl_la_OBJECTS) $(libstl_la_DEPENDENCIES) $(CXXLINK) $(libstl_la_OBJECTS) $(libstl_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/meshstlsurface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stlgeom.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stlgeomchart.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stlgeommesh.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stlline.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stltool.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stltopology.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) $(HEADERS) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-exec-am: install-html: install-html-am install-info: install-info-am install-man: install-pdf: install-pdf-am install-ps: install-ps-am installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool clean-noinstLTLIBRARIES ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: netgen-4.9.13/libsrc/stlgeom/stlline.hpp0000644000175000001440000001144011240003503015104 00000000000000#ifndef FILE_STLLINE #define FILE_STLLINE /**************************************************************************/ /* File: stlline.hh */ /* Author: Joachim Schoeberl */ /* Author2: Johannes Gerstmayr */ /* Date: 20. Nov. 99 */ /**************************************************************************/ class STLGeometry; class STLTopology; class STLEdge { public: int pts[2]; int trigs[2]; //left and right trig STLEdge (const int * apts) {pts[0] = apts[0]; pts[1] = apts[1];} STLEdge (int v1, int v2) {pts[0] = v1; pts[1] = v2;} STLEdge () {pts[0]=0;pts[1]=0;} int PNum(int i) const {return pts[(i-1)];} int LeftTrig() const {return trigs[0];} int RightTrig() const {return trigs[1];} void SetLeftTrig(int i) {trigs[0] = i;} void SetRightTrig(int i) {trigs[1] = i;} }; enum STL_ED_STATUS { ED_EXCLUDED, ED_CONFIRMED, ED_CANDIDATE, ED_UNDEFINED }; /* class STLEdgeData { public: // float angle; int p1; int p2; int lt; //left trig int rt; //right trig // int status; STLTopology * top; // pointer to stl topology int topedgenr; // number of corresponding topology edge STLEdgeData() {}; STLEdgeData(float anglei, int p1i, int p2i, int lti, int rti) { // angle = anglei; p1 = p1i; p2 = p2i; lt = lti; rt = rti; } int GetStatus () const; void SetStatus (int stat); void SetExcluded() { SetStatus (ED_EXCLUDED); } void SetConfirmed() { SetStatus (ED_CONFIRMED); } void SetCandidate() { SetStatus (ED_CANDIDATE); } void SetUndefined() { SetStatus (ED_UNDEFINED); } int Excluded() const {return GetStatus() == ED_EXCLUDED;} int Confirmed() const {return GetStatus() == ED_CONFIRMED;} int Candidate() const {return GetStatus() == ED_CANDIDATE;} int Undefined() const {return GetStatus() == ED_UNDEFINED;} int ConfCand() const {return GetStatus() == ED_CONFIRMED || GetStatus() == ED_CANDIDATE;} float CosAngle() const; void Write(ofstream& of) const; void Read(ifstream& ifs); }; class STLEdgeDataList { private: INDEX_2_HASHTABLE hashtab; Array edgedata; TABLE edgesperpoint; public: STLEdgeDataList():edgedata(),hashtab(1),edgesperpoint() {}; const STLEdgeDataList& operator=(const STLEdgeDataList& edl); void SetSize(int size) { edgedata.SetSize(size); hashtab.SetSize(size); edgesperpoint.SetSize(size); } void Clear() {SetSize(0);} int Size() const {return edgedata.Size();} const STLEdgeData& Get(int i) const {return edgedata.Get(i);} STLEdgeData& Elem(int i) {return edgedata.Elem(i);} void Add(const STLEdgeData& ed, int i); int GetNEPP(int pn) const { return edgesperpoint.EntrySize(pn); }; int GetEdgePP(int pn, int vi) const { return edgesperpoint.Get(pn,vi); }; void AddEdgePP(int pn, int vn) {edgesperpoint.Add(pn,vn);}; void ResetAll(); void ResetCandidates(); void ConfirmCandidates(); int GetEdgeNum(int np1, int np2) const; int GetNConfEdges() const; void Write(ofstream& of) const; void Read(ifstream& ifs); void BuildLineWithEdge(int ep1, int ep2, Array& line); int GetNEPPStat(int p, int status) const; int GetNConfCandEPP(int p) const; }; */ //a line defined by several points (polyline) class STLLine { private: const STLGeometry * geometry; Array pts; Array lefttrigs; Array righttrigs; Array dists; int split; public: STLLine(const STLGeometry * ageometry); void AddPoint(int i) {pts.Append(i);} int PNum(int i) const {return pts.Get(i);} int NP() const {return pts.Size();} int GetNS() const; void GetSeg(int nr, int& p1, int& p2) const; double GetSegLen(const Array >& ap, int nr) const; int GetLeftTrig(int nr) const; int GetRightTrig(int nr) const; double GetDist(int nr) const { return dists.Get(nr);}; void GetBoundingBox (const Array > & ap, Box<3> & box) const; void AddLeftTrig(int nr) {lefttrigs.Append(nr);} void AddRightTrig(int nr) {righttrigs.Append(nr);} void AddDist (double dist) {dists.Append(dist); } int StartP() const {return pts.Get(1);} int EndP() const {return pts.Get(pts.Size());} double GetLength(const Array >& ap) const; //suche punkt in entfernung (in linienkoordinaten) dist //in index ist letzter punkt VOR dist (d.h. max pts.Size()-1) Point<3> GetPointInDist(const Array >& ap, double dist, int& index) const; //return a meshed polyline STLLine* Mesh(const Array >& ap, Array& mp, double ghi, class Mesh& mesh) const; void DoSplit() {split = 1;} int ShouldSplit() const {return split;} }; #endif netgen-4.9.13/libsrc/stlgeom/stltopology.hpp0000644000175000001440000002363311240003503016040 00000000000000#ifndef FILE_STLTOPOLOGY #define FILE_STLTOPOLOGY /**************************************************************************/ /* File: stltopology.hpp */ /* Author: Joachim Schoeberl */ /* Author2: Johannes Gerstmayr */ /* Date: 26. Jul. 99 */ /**************************************************************************/ /* The STLTopology contains topologic information as triangle->point, point->triangles, triangle->edge, 2-points->edge,... */ class STLGeometry; #define STLBASE 1 class STLPointIndex { int i; public: STLPointIndex () { ; } STLPointIndex (int ai) : i(ai) { ; } STLPointIndex & operator= (const STLPointIndex & ai) { i = ai.i; return *this; } STLPointIndex & operator= (int ai) { i = ai; return *this; } operator int () const { return i; } STLPointIndex operator++ (int) { return i++; } STLPointIndex operator-- (int) { return i--; } }; class STLTrigIndex { int i; public: STLTrigIndex () { ; } STLTrigIndex (int ai) : i(ai) { ; } STLTrigIndex & operator= (const STLTrigIndex & ai) { i = ai.i; return *this; } STLTrigIndex & operator= (int ai) { i = ai; return *this; } operator int () const { return i; } STLTrigIndex operator++ (int) { return i++; } STLTrigIndex operator-- (int) { return i--; } }; // triangle structure for loading stl files class STLReadTriangle { Vec<3> normal; Point<3> pts[3]; public: STLReadTriangle (const Point<3> * apts, const Vec<3> & anormal); STLReadTriangle () {}; const Point<3> & operator[] (int i) const { return pts[i]; } const Vec<3> & Normal() const { return normal; } }; class STLTriangle { // topology edges of triangle, edge[i] opposite to point[i] int topedges[3]; // neighbour triangles, trig[i] opposite to point[i] int nbtrigs[2][3]; // normalized stored normal vector ?? Vec<3> normal; // point numbers of triangle int pts[3]; // front-side and back-side domains int domains[2]; public: Box<3> box; Point<3> center; double rad; int facenum; struct { unsigned int toperror : 1; } flags; STLTriangle (const int * apts); STLTriangle () {pts[0]=0;pts[1]=0;pts[2]=0;} int operator[] (int i) const { return pts[i]; } int & operator[] (int i) { return pts[i]; } int EdgeNum(int i) const { return topedges[(i-1)]; } int & EdgeNum(int i) { return topedges[(i-1)]; } int NBTrig (bool side, int i) const { return nbtrigs[side][i]; } int & NBTrig (bool side, int i) { return nbtrigs[side][i]; } int Domain (bool side) const { return domains[side]; } int & Domain (bool side) { return domains[side]; } // obsolete: int PNum(int i) const { return pts[(i-1)]; } int & PNum(int i) { return pts[(i-1)]; } int PNumMod(int i) const { return pts[(i-1)%3]; } int & PNumMod(int i) { return pts[(i-1)%3]; } int EdgeNumMod(int i) const { return topedges[(i-1)%3]; } int & EdgeNumMod(int i) { return topedges[(i-1)%3]; } int NBTrigNum(int i) const { return nbtrigs[0][(i-1)]; } int & NBTrigNum(int i) { return nbtrigs[0][(i-1)]; } int NBTrigNumMod(int i) const { return nbtrigs[0][(i-1)%3]; } int & NBTrigNumMod(int i) { return nbtrigs[0][(i-1)%3]; } // consistently oriented neighbour: int IsNeighbourFrom(const STLTriangle& t) const; // opposite to consistently oriented neighbour: int IsWrongNeighbourFrom(const STLTriangle& t) const; ///Get the two points of neighbour-Triangles in orientation of this-Triangle void GetNeighbourPoints(const STLTriangle& t, int& p1, int& p2) const; int GetNeighbourPointsAndOpposite(const STLTriangle& t, int& p1, int& p2, int& po) const; // NON-normalized geometry - normal vector Vec<3> GeomNormal(const Array >& ap) const; // Stored normal vector, normalized void SetNormal (const Vec<3> & n); const Vec<3> & Normal () const { return normal; } void ChangeOrientation(); //project with a certain normal vector in plane void ProjectInPlain(const Array >& ap, const Vec<3> & n, Point<3> & pp) const; //project with the triangle's normal vector in plane void ProjectInPlain(const Array > & ap, Point<3> & pp) const; /* Project the point pp along the nproj into the plane of the triangle. The triangle normal is given by ntrig to avoid numerical instabilities. The local coordinates lam are defined by pp(input) = P1 + lam1 v1 + lam2 v2 + lam3 n the result is pp(output) = P1 + lam1 v1 + lam2 v2 */ int ProjectInPlain (const Array >& ap, const Vec<3> & nproj, Point<3> & pp, Vec<3> & lam) const; int PointInside(const Array >& ap, const Point<3> & pp) const; //get nearest point on triangle and distance to it double GetNearestPoint(const Array >& ap, Point<3> & p3d) const; double Area(const Array >& ap) const; double MinHeight(const Array >& ap) const; double MaxLength(const Array >& ap) const; //max length of a side of triangle int GetFaceNum() {return facenum;} void SetFaceNum(int i) {facenum = i;} int HasEdge(int p1, int p2) const; }; /** Topology Edge: Useful unside a face. A edges sharing more than 2 faces: trigs are undefined */ class STLTopEdge { int pts[2]; int trigs[2]; double cosangle; int status; // excluded, confirmed, candidate, undefined public: STLTopEdge (); STLTopEdge (int p1, int p2, int trig1, int trig2); int operator[] (int i) const { return pts[i]; } int & operator[] (int i) { return pts[i]; } int PNum(int i) const { return pts[(i-1)]; } int & PNum(int i) { return pts[(i-1)]; } int PNumMod(int i) const { return pts[(i-1)%2]; } int & PNumMod(int i) { return pts[(i-1)%2]; } int TrigNum(int i) const { return trigs[(i-1)]; } int & TrigNum(int i) { return trigs[(i-1)]; } int TrigNumMod(int i) const { return trigs[(i-1)%2]; } int & TrigNumMod(int i) { return trigs[(i-1)%2]; } void SetCosAngle (double ca) { cosangle = ca; } double CosAngle () const { return cosangle; } double Angle () const { return acos (cosangle); } void SetStatus (int stat) { status = stat; } int GetStatus () const { return status; } }; ostream& operator<<(ostream& os, const STLTriangle& t); class STLTopology { protected: Array trias; Array topedges; Array > points; // mapping of sorted pair of points to topedge INDEX_2_HASHTABLE * ht_topedges; // mapping of node to trigs TABLE trigsperpoint; // mapping of node to edges TABLE topedgesperpoint; // searchtree for trigs and points Box3dTree * searchtree; // ADT Point3dTree * pointtree; Box<3> boundingbox; double pointtol; public: enum STL_GEOM_STATUS { STL_GOOD, STL_WARNING, STL_ERROR }; protected: STL_GEOM_STATUS status; string statustext; bool topology_ok; bool orientation_ok; public: STLTopology(); virtual ~STLTopology(); static STLGeometry * LoadNaomi (istream & ist); static STLGeometry * Load (istream & ist); static STLGeometry * LoadBinary (istream & ist); void Save (const char* filename); void SaveBinary (const char* filename, const char* aname); void SaveSTLE (const char * filename); // stores trigs and edges virtual void InitSTLGeometry (const Array & readtrigs); virtual void TopologyChanged() {}; //do some things, if topology changed! /// Generate topology tables void FindNeighbourTrigs(); void GetTrianglesInBox (const Box<3> & box, Array & trias) const; int GetNP() const { return points.Size(); } int AddPoint(const Point<3> & p) { return points.Append(p); } const Point<3> & GetPoint(int nr) const { return points.Get(nr); } int GetPointNum (const Point<3> & p); void SetPoint(int nr, const Point<3> & p) { points.Elem(nr) = p; } const Array >& GetPoints() const { return points; } const Point<3> & operator[] (STLPointIndex i) const { return points[i]; } Point<3> & operator[] (STLPointIndex i) { return points[i]; } int GetNT() const { return trias.Size(); } void AddTriangle(const STLTriangle& t); const STLTriangle & GetTriangle (int nr) const { return trias.Get(nr); } STLTriangle & GetTriangle (int nr) { return trias.Elem(nr); } const STLTriangle & operator[] (STLTrigIndex i) const { return trias[i]; } STLTriangle & operator[] (STLTrigIndex i) { return trias[i]; } int GetNTE() const { return topedges.Size(); } const STLTopEdge & GetTopEdge (int nr) const { return topedges.Get(nr); } STLTopEdge & GetTopEdge (int nr) { return topedges.Elem(nr); } int GetTopEdgeNum (int pi1, int pi2) const; int NOTrigsPerPoint(int pn) { return trigsperpoint.EntrySize(pn); } int TrigPerPoint(int pn, int i) { return trigsperpoint.Get(pn, i); } int NTopEdgesPerPoint (int pn) const { return topedgesperpoint.EntrySize(pn); } int TopEdgePerPoint (int pn, int ei) const { return topedgesperpoint.Get(pn, ei); } bool Topology_Ok() const { return topology_ok; } bool Orientation_Ok() const { return orientation_ok; } STL_GEOM_STATUS GetStatus () const { return status; } const string & GetStatusText () const { return statustext; } void InvertTrig (int trig); void DeleteTrig (int trig); void OrientAfterTrig (int trig); // Table will be constructed, if topology is not ok /// neighbourtrigs for surfacetrigs TABLE neighbourtrigs; /// get nr-th neighbour Triangle for triangle trig int NONeighbourTrigs(int trig) const { return neighbourtrigs.EntrySize(trig); } int NeighbourTrig(int trig, int nr) const { return neighbourtrigs.Get(trig,nr); } int NeighbourTrigSorted(int trig, int nr) const; void AddNeighbourTrig(int i, int nt) { neighbourtrigs.Add1(i, nt); } int GetLeftTrig (int p1, int p2) const; int GetRightTrig (int p1, int p2) const; const Box<3> & GetBoundingBox () const { return boundingbox; } }; #endif netgen-4.9.13/libsrc/stlgeom/stltool.hpp0000644000175000001440000001634111240003503015137 00000000000000#ifndef FILE_STLTOOL #define FILE_STLTOOL //#include "gprim/gprim.hh" /**************************************************************************/ /* File: stlgeom.hh */ /* Author: Joachim Schoeberl */ /* Author2: Johannes Gerstmayr */ /* Date: 20. Nov. 99 */ /**************************************************************************/ // use one normal vector for whole chart extern int usechartnormal; extern int chartdebug; extern int geomsearchtreeon; extern int AddPointIfNotExists(Array& ap, const Point3d& p, double eps = 1e-8); //get distance from line lp1-lp2 to point p extern double GetDistFromLine(const Point<3>& lp1, const Point<3>& lp2, Point<3>& p); extern double GetDistFromInfiniteLine(const Point<3>& lp1, const Point<3>& lp2, const Point<3>& p); extern void FIOReadInt(istream& ios, int& i); extern void FIOWriteInt(ostream& ios, const int& i); extern void FIOReadDouble(istream& ios, double& i); extern void FIOWriteDouble(ostream& ios, const double& i); extern void FIOReadFloat(istream& ios, float& i); extern void FIOWriteFloat(ostream& ios, const float& i); extern void FIOReadString(istream& ios, char* str, int len); extern void FIOReadStringE(istream& ios, char* str, int len); extern void FIOWriteString(ostream& ios, char* str, int len); typedef Array * ArrayINTPTR; class STLGeometry; class STLChart { private: STLGeometry * geometry; Array* charttrigs; // trigs which only belong to this chart Array* outertrigs; // trigs which belong to other charts Box3dTree * searchtree; // ADT containing outer trigs Array* olimit; //outer limit of outer chart Array* ilimit; //outer limit of inner chart public: STLChart(STLGeometry * ageometry); void AddChartTrig(int i); void AddOuterTrig(int i); int IsInWholeChart(int nr) const; int GetChartTrig(int i) const {return charttrigs->Get(i);} int GetOuterTrig(int i) const {return outertrigs->Get(i);} //get all trigs: int GetTrig(int i) const { if (i <= charttrigs->Size()) {return charttrigs->Get(i);} else {return outertrigs->Get(i-charttrigs->Size());} } int GetNChartT() const {return charttrigs->Size();} int GetNOuterT() const {return outertrigs->Size();} int GetNT() const {return charttrigs->Size()+outertrigs->Size(); } void GetTrianglesInBox (const Point3d & pmin, const Point3d & pmax, Array & trias) const; void AddOLimit(twoint l) {olimit->Append(l);} void AddILimit(twoint l) {ilimit->Append(l);} void ClearOLimit() {olimit->SetSize(0);} void ClearILimit() {ilimit->SetSize(0);} int GetNOLimit() const {return olimit->Size();} int GetNILimit() const {return ilimit->Size();} twoint GetOLimit(int i) const {return olimit->Get(i);} twoint GetILimit(int i) const {return ilimit->Get(i);} //move triangles trigs (local chart-trig numbers) to outer chart void MoveToOuterChart(const Array& trigs); void DelChartTrigs(const Array& trigs); // define local coordinate system, JS: private: Vec<3> normal; Point<3> pref; Vec<3> t1, t2; public: void SetNormal (const Point<3> & apref, const Vec<3> & anormal); const Vec<3> & GetNormal () const { return normal; } Point<2> Project2d (const Point<3> & p3d) const; }; class STLBoundarySeg { Point<3> p1, p2, center; Point<2> p2d1, p2d2; Box<2> boundingbox; // Point<2> p2dmin, p2dmax; double rad; int i1, i2; int smoothedge; public: STLBoundarySeg () { ; } STLBoundarySeg (int ai1, int ai2, const Array > & points, const STLChart * achart); int operator== (const STLBoundarySeg & s2) const { return i1 == s2.i1 && i2 == s2.i2; } void Swap (); int I1() const { return i1; } int I2() const { return i2; } const Point<3> & P1() const { return p1; } const Point<3> & P2() const { return p2; } const Point<2> & P2D1() const { return p2d1; } const Point<2> & P2D2() const { return p2d2; } const Point<2> & P2DMin() const { return boundingbox.PMin(); } const Point<2> & P2DMax() const { return boundingbox.PMax(); } const Point<3> & Center() const { return center; } const Box<2> & BoundingBox() const { return boundingbox; } double Radius () const { return rad; } void SetSmoothEdge (int se) { smoothedge = se; } int IsSmoothEdge () const { return smoothedge; } friend class STLBoundary; }; class STLBoundary { private: STLGeometry * geometry; const STLChart * chart; Array boundary; public: STLBoundary(STLGeometry * ageometry); // : boundary() {}; void Clear() {boundary.SetSize(0);}; void SetChart (const STLChart * achart) { chart = achart; } //don't check, if already exists! void AddNewSegment(const STLBoundarySeg & seg) {boundary.Append(seg);}; //check if segment exists void AddOrDelSegment(const STLBoundarySeg & seg); //addordelsegment for all 3 triangle segments! void AddTriangle(const STLTriangle & t); int NOSegments() {return boundary.Size();}; const STLBoundarySeg & GetSegment(int i) {return boundary.Get(i);} int TestSeg(const Point<3> & p1, const Point<3> & p2, const Vec<3> & sn, double sinchartangle, int divisions, Array >& points, double eps); int TestSegChartNV(const Point3d& p1, const Point3d& p2, const Vec3d& sn); }; class STLDoctorParams { public: int drawmeshededges; double geom_tol_fact; double longlinefact; int showexcluded; int selectmode; //0==trig, 1==edge, 2==point, 3==multiedge, 4==line cluster int edgeselectmode; int useexternaledges; int showfaces; int showedgecornerpoints; int showtouchedtrigchart; int conecheck; int spiralcheck; int selecttrig; int nodeofseltrig; int selectwithmouse; int showmarkedtrigs; double dirtytrigfact; double smoothangle; double smoothnormalsweight; int showvicinity; int vicinity; /// STLDoctorParams(); /// void Print (ostream & ost) const; }; extern STLDoctorParams stldoctor; class STLParameters { public: /// angle for edge detection double yangle; double contyangle; //edges continued with contyangle /// angle of geometry edge at which the mesher should set a point double edgecornerangle; /// angle inside on chart double chartangle; /// angle for overlapping parts of char double outerchartangle; /// 0 .. no, 1 .. local, (2 .. global) int usesearchtree; /// double resthatlasfac; int resthatlasenable; double atlasminh; double resthsurfcurvfac; int resthsurfcurvenable; double resthchartdistfac; int resthchartdistenable; double resthcloseedgefac; int resthcloseedgeenable; double resthedgeanglefac; int resthedgeangleenable; double resthsurfmeshcurvfac; int resthsurfmeshcurvenable; double resthlinelengthfac; int resthlinelengthenable; /// int recalc_h_opt; /// STLParameters(); /// void Print (ostream & ost) const; }; extern STLParameters stlparam; void STLMeshing (STLGeometry & geom, class Mesh & mesh); int STLSurfaceMeshing (STLGeometry & geom, class Mesh & mesh); void STLSurfaceOptimization (STLGeometry & geom, class Mesh & mesh, class MeshingParameters & mparam); #endif netgen-4.9.13/libsrc/stlgeom/meshstlsurface.hpp0000644000175000001440000000626711240003503016475 00000000000000#ifndef FILE_MESHSTLSURF #define FILE_MESHSTLSURF /* *************************************************************************/ /* File: meshstlsurf.hpp */ /* Author: Johannes Gerstmayr, Joachim Schoeberl */ /* Date: 01. Aug. 99 */ /* *************************************************************************/ /* The interface between mesh generation and stl geometry */ /// class MeshingSTLSurface : public Meshing2 { /// STLGeometry & geom; /// int transformationtrig; public: /// MeshingSTLSurface (STLGeometry & ageom); protected: /// virtual void DefineTransformation (const Point3d & p1, const Point3d & p2, const PointGeomInfo * geominfo1, const PointGeomInfo * geominfo2); /// virtual void TransformToPlain (const Point3d & locpoint, const MultiPointGeomInfo & geominfo, Point2d & plainpoint, double h, int & zone); /// virtual int TransformFromPlain (Point2d & plainpoint, Point3d & locpoint, PointGeomInfo & gi, double h); /// virtual int BelongsToActiveChart (const Point3d & p, const PointGeomInfo & gi); /// virtual int ComputePointGeomInfo (const Point3d & p, PointGeomInfo & gi); /// virtual int ChooseChartPointGeomInfo (const MultiPointGeomInfo & mpgi, PointGeomInfo & pgi); /// virtual int IsLineVertexOnChart (const Point3d & p1, const Point3d & p2, int endpoint, const PointGeomInfo & gi); virtual void GetChartBoundary (Array & points, Array & poitns3d, Array & lines, double h) const; /// virtual double CalcLocalH (const Point3d & p, double gh) const; /// virtual double Area () const; }; /// class MeshOptimizeSTLSurface : public MeshOptimize2d { /// STLGeometry & geom; public: /// MeshOptimizeSTLSurface (STLGeometry & ageom); /// virtual void SelectSurfaceOfPoint (const Point<3> & p, const PointGeomInfo & gi); /// virtual void ProjectPoint (INDEX surfind, Point<3> & p) const; /// virtual void ProjectPoint2 (INDEX surfind, INDEX surfind2, Point<3> & p) const; /// virtual int CalcPointGeomInfo(PointGeomInfo& gi, const Point<3> & p3) const; /// virtual void GetNormalVector(INDEX surfind, const Point<3> & p, Vec<3> & n) const; }; class RefinementSTLGeometry : public Refinement { const STLGeometry & geom; public: RefinementSTLGeometry (const STLGeometry & ageom); virtual ~RefinementSTLGeometry (); virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint, int surfi, const PointGeomInfo & gi1, const PointGeomInfo & gi2, Point<3> & newp, PointGeomInfo & newgi); virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint, int surfi1, int surfi2, const EdgePointGeomInfo & ap1, const EdgePointGeomInfo & ap2, Point<3> & newp, EdgePointGeomInfo & newgi); virtual void ProjectToSurface (Point<3> & p, int surfi); virtual void ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi); }; #endif netgen-4.9.13/libsrc/stlgeom/stlgeom.hpp0000644000175000001440000003243411244763264015137 00000000000000#ifndef FILE_STLGEOM #define FILE_STLGEOM /**************************************************************************/ /* File: stlgeom.hpp */ /* Author: Joachim Schoeberl */ /* Author2: Johannes Gerstmayr */ /* Date: 26. Jul. 99 */ /**************************************************************************/ /** STL Geometry Terminology: Point ... coordinates of STL triangles Triangle (short Trig) STL triangle TopEdge .... edge in topology, boundary of STL triangles (many) Edge .... Edges which will occur in the mesh (confirmed edges, less) */ #include #include namespace netgen { extern int IsInArray(int n, const Array& ia); extern int AddIfNotExists(Array& list, int x); #include "stltopology.hpp" #include "stltool.hpp" #include "stlline.hpp" class STLEdgeDataList { Array storedstatus; STLTopology & geom; public: STLEdgeDataList(STLTopology & ageom); ~STLEdgeDataList(); void Store (); void Restore (); void SetSize(int /* size */) { }; void Clear() { }; int Size() const { return geom.GetNTE(); } const STLTopEdge & Get(int i) const { return geom.GetTopEdge(i); } STLTopEdge & Elem(int i) { return geom.GetTopEdge(i); } int GetNEPP(int pn) const {return geom.NTopEdgesPerPoint(pn); } int GetEdgePP(int pn, int vi) const {return geom.TopEdgePerPoint(pn, vi);}; //void AddEdgePP(int pn, int vn) { } ; void ResetAll(); void ChangeStatus(int status1, int status2); int GetEdgeNum(int np1, int np2) const { return geom.GetTopEdgeNum (np1, np2); } int GetNConfEdges() const; void Write(ofstream& of) const; void Read(ifstream& ifs); void BuildLineWithEdge(int ep1, int ep2, Array& line); void BuildClusterWithEdge(int ep1, int ep2, Array& line); int GetNEPPStat(int p, int status) const; int GetNConfCandEPP(int p) const; }; class STLGeometry : public STLTopology, public NetgenGeometry { // edges to be meshed: Array edges; //edges per point TABLE edgesperpoint; // line: a connection of edges Array lines; Array lineendpoints; //per geometrypoint, 1 = is endpoint; 0 = no endpoint, Array normals; //normals belong to points! Array externaledges; int undoexternaledges; Array storedexternaledges; STLEdgeDataList * edgedata; // STLEdgeDataList edgedata_store; int calcedgedataanglesnew; int edgedatastored; int facecnt; //meshpoint is only set, if an edge is at this point!!! Array vicinity; //is one, if a triangle belongs to vicinity (eg. of selecttrig) Array markedtrigs; //is one, if a triangle belongs to marked triangles (calcdirtystrigs) Array markedsegs; //every pointpair is a segment!!! Array selectedmultiedge; //spiralpoints: Array spiralpoints; // Array atlas; //marks all already charted trigs with chartnumber Array chartmark; //outerchartspertrig, ascending sorted TABLE outerchartspertrig; //for meshing and project: Array meshcharttrigs; //per trig: 1=belong to chart, 0 not int meshchart; Array ha_points; // help array, np long, filled with 0 // sharp geometric edges not declared as edges // (not considered for spiral check) INDEX_2_HASHTABLE * smoothedges; //transformation: Vec<3> meshtrignv; Vec<3> ex, ey, ez; Point<3> p1; public: int edgesfound; int surfacemeshed; int surfaceoptimized; int volumemeshed; int trigsconverted; //when STLTriangles exist -> 1 //for selecting nodes //int selecttrig, nodeofseltrig; //only for testing; Array meshlines; Array meshpoints; public: STLGeometry(); virtual ~STLGeometry(); void Clear(); void STLInfo(double* data); //stldoctor: void SmoothNormals(); void MarkNonSmoothNormals(); void CalcEdgeData(); void CalcEdgeDataAngles(); const STLEdgeDataList& EdgeDataList() const {return *edgedata;} void UndoEdgeChange(); void StoreEdgeData(); void RestoreEdgeData(); //void ClearSelectedMultiEdge() {selectedmultiedge.SetSize(0);} //void AddSelectedMultiEdge(twoint ep) {selectedmultiedge.Append(ep);} //int SelectedMultiEdgeSize() {return selectedmultiedge.Size();} const Array& SelectedMultiEdge() {return selectedmultiedge;} twoint GetNearestSelectedDefinedEdge(); void BuildSelectedMultiEdge(twoint ep); void BuildSelectedEdge(twoint ep); void BuildSelectedCluster(twoint ep); void ImportEdges(); void AddEdges(const Array >& eps); void ExportEdges(); void LoadEdgeData(const char* file); void SaveEdgeData(const char* file); // void SetEdgeAtSelected(int mode); void STLDoctorConfirmEdge(); void STLDoctorCandidateEdge(); void STLDoctorExcludeEdge(); void STLDoctorUndefinedEdge(); void STLDoctorSetAllUndefinedEdges(); void STLDoctorEraseCandidateEdges(); void STLDoctorConfirmCandidateEdges(); void STLDoctorConfirmedToCandidateEdges(); void STLDoctorDirtyEdgesToCandidates(); void STLDoctorLongLinesToCandidates(); void UndoExternalEdges(); void StoreExternalEdges(); void RestoreExternalEdges(); void ImportExternalEdges(const char * filename); // Flame edges, JS // void LoadExternalEdges(); void BuildExternalEdgesFromEdges(); void SaveExternalEdges(); void AddExternalEdgeAtSelected(); void AddClosedLinesToExternalEdges(); void AddLongLinesToExternalEdges(); void AddAllNotSingleLinesToExternalEdges(); void STLDoctorBuildEdges(); void AddExternalEdgesFromGeomLine(); void DeleteDirtyExternalEdges(); void DeleteExternalEdgeAtSelected(); void DeleteExternalEdgeInVicinity(); void AddExternalEdge(int p1, int p2); void DeleteExternalEdge(int p1, int p2); int IsExternalEdge(int p1, int p2); int NOExternalEdges() const {return externaledges.Size();} twoint GetExternalEdge(int i) const {return externaledges.Get(i);} void DestroyDirtyTrigs(); void CalcNormalsFromGeometry(); void MoveSelectedPointToMiddle(); void NeighbourAnglesOfSelectedTrig(); void PrintSelectInfo(); void ShowSelectedTrigChartnum(); void ShowSelectedTrigCoords(); void SmoothGeometry (); void LoadMarkedTrigs(); void SaveMarkedTrigs(); void ClearMarkedSegs() {markedsegs.SetSize(0);} void AddMarkedSeg(const Point<3> & ap1, const Point<3> & ap2) { markedsegs.Append(ap1);markedsegs.Append(ap2); } void GetMarkedSeg(int i, Point<3> & ap1, Point<3> & ap2) { ap1=markedsegs.Get(i*2-1); ap2=markedsegs.Get(i*2); } int GetNMarkedSegs() {return markedsegs.Size()/2;} void CalcVicinity(int starttrig); void GetVicinity(int starttrig, int size, Array& vic); int Vicinity(int trig) const; void InitMarkedTrigs(); void MarkDirtyTrigs(); void SmoothDirtyTrigs(); void GeomSmoothRevertedTrigs(); void MarkRevertedTrigs(); double CalcTrigBadness(int i); int IsMarkedTrig(int trig) const; void SetMarkedTrig(int trig, int num); void MarkTopErrorTrigs (); //Selected triangle void SetSelectTrig(int trig); int GetSelectTrig() const; void SetNodeOfSelTrig(int n); int GetNodeOfSelTrig() const; int AddNormal(const Vec3d& n) {return normals.Append(n);} const Vec3d & GetNormal(int nr) const {return normals.Get(nr);} void SetNormal(int nr, const Vec3d& n) {normals.Elem(nr) = n;} int AddEdge(const STLEdge& v) {return edges.Append(v);} int AddEdge(int p1, int p2); STLEdge GetEdge(int nr) {return edges.Get(nr);} int GetNE() {return edges.Size();} double Area(); double GetAngle(int t1, int t2); double GetGeomAngle(int t1, int t2); //if triangles t1 and t2 touch, return 1 and in p1, p2 the touching points //int TrigsTouch(int t1, int t2, int& p1, int& p2); /// ///ReadTriangle->STLTriangle, initialise some important variables, always after load!!! virtual void InitSTLGeometry (const Array & readtrigs); virtual void TopologyChanged(); //do some things, if topology changed! int CheckGeometryOverlapping(); //get NO edges per point int GetEPPSize() const {return edgesperpoint.Size();}; int GetNEPP(int pn) { if (edgesperpoint.Size() == 0) {BuildEdgesPerPoint();} return edgesperpoint.EntrySize(pn); }; int GetEdgePP(int pn, int vi) { if (edgesperpoint.Size() == 0) {BuildEdgesPerPoint();} return edgesperpoint.Get(pn,vi); }; void AddEdgePP(int pn, int vn) {edgesperpoint.Add1(pn,vn);}; //von 2 punkten ermitteln, ob sie eine Kante sind int IsEdge(int p1, int p2); int IsEdgeNum(int p1, int p2); ///Build EdgeSegments void ClearEdges(); void BuildEdges(); void BuildEdgesPerPoint(); void UseExternalEdges(); void FindEdgesFromAngles(); void CalcFaceNums(); int GetNOBodys(); int GetNOFaces() {return facecnt;} void LinkEdges(); void AddConeAndSpiralEdges(); void AddFaceEdges(); //each face should have at least one starting edge (outherwise it won't be meshed) void GetDirtyChartTrigs(int chartnum, STLChart& chart, const Array& outercharttrigs, Array& chartpointchecked, Array& dirtytrigs); void ClearSpiralPoints(); void SetSpiralPoint(int pn) {spiralpoints.Elem(pn) = 1;}; int GetSpiralPoint(int pn) const {return spiralpoints.Get(pn);}; void GetSortedTrianglesAroundPoint(int p, int starttrig, Array& trigs); // smooth edges: sharp geometric edges not declared as edges void BuildSmoothEdges (); int IsSmoothEdge (int pi1, int pi2) const; //make charts with regions of a max. angle void MakeAtlas(class Mesh & mesh); //outerchartspertrig, sorted! int GetOCPTSize() const {return outerchartspertrig.Size();}; int GetNOCPT(int tn) const {return outerchartspertrig.EntrySize(tn);}; int GetOCPT(int tn, int vi) const {return outerchartspertrig.Get(tn,vi);}; void SetOCPT(int tn, int vi, int ocn) {outerchartspertrig.Set(tn,vi,ocn);}; void AddOCPT(int tn, int ocn) {outerchartspertrig.Add1(tn, ocn);}; int TrigIsInOC(int tn, int ocn) const; //get chart number of a trig or 0 if unmarked int GetChartNr(int i) const; int GetMarker(int i) const { return chartmark.Get(i); } void SetMarker(int nr, int m); int GetNOCharts() const; //get a chart from atlas const STLChart& GetChart(int nr) const; STLChart& GetChart(int nr) {return *(atlas.Get(nr));}; int AtlasMade() const; void GetInnerChartLimes(Array& limes, int chartnum); //FOR MESHING int GetMeshChartNr () { return meshchart; } void GetMeshChartBoundary (Array & points, Array & points3d, Array & lines, double h); Point<3> PointBetween(const Point<3> & p1, int t1, const Point<3> & p2, int t2); //select triangles in meshcharttrigs of actual (defined by trig) whole chart void PrepareSurfaceMeshing(); // void DefineTangentialPlane(const Point<3> & ap1, const Point<3> & ap2, int trig); // void SelectChartOfTriangle (int trignum); // void SelectChartOfPoint (const Point<3> & p); // const Vec<3> & GetChartNormalVector () const { return meshtrignv; } // list of trigs void ToPlane (const Point<3> & locpoint, int * trigs, Point<2> & plainpoint, double h, int& zone, int checkchart); //return 0, wenn alles OK, 1 sonst int FromPlane (const Point<2> & plainpoint, Point<3> & locpoint, double h); //get nearest point in actual chart and return any triangle where it lies on int ProjectNearest(Point<3> & p3d) const; //project point with normal nv from last define tangential plane int LastTrig() const; int Project(Point<3> & p3d) const; int ProjectOnWholeSurface (Point<3> & p3d) const; int GetNLines() const {return lines.Size();} int AddLine(STLLine* line) {return lines.Append(line);} STLLine* GetLine(int nr) const {return lines.Get(nr);} int GetLineP(int lnr, int pnr) const {return lines.Get(lnr)->PNum(pnr);} int GetLineNP(int nr) const {return lines.Get(nr)->NP();} void SetLineEndPoint(int pn); int IsLineEndPoint(int pn); int LineEndPointsSet() const {return lineendpoints.Size() == GetNP();} void ClearLineEndPoints(); void RestrictLocalH(class Mesh & mesh, double gh); void RestrictLocalHCurv(class Mesh & mesh, double gh); void RestrictHChartDistOneChart(int chartnum, Array& acttrigs, class Mesh & mesh, double gh, double fact, double minh); friend class MeshingSTLSurface; virtual int GenerateMesh (Mesh*& mesh, int perfstepsstart, int perfstepsend, char* optstring); virtual const Refinement & GetRefinement () const; }; #include "meshstlsurface.hpp" extern int STLMeshingDummy (STLGeometry* stlgeometry, Mesh*& mesh, int perfstepsstart, int perfstepsend, char* optstring); } #endif netgen-4.9.13/libsrc/stlgeom/stlgeom.cpp0000644000175000001440000022517411244763655015143 00000000000000#include #include #include #include #include #include "stlgeom.hpp" namespace netgen { //globalen searchtree fuer gesamte geometry aktivieren int geomsearchtreeon = 0; int usechartnormal = 1; //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ void STLMeshing (STLGeometry & geom, Mesh & mesh) { geom.Clear(); geom.BuildEdges(); geom.MakeAtlas(mesh); geom.CalcFaceNums(); geom.AddFaceEdges(); geom.LinkEdges(); mesh.ClearFaceDescriptors(); for (int i = 1; i <= geom.GetNOFaces(); i++) mesh.AddFaceDescriptor (FaceDescriptor (i, 1, 0, 0)); } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++ STL GEOMETRY ++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ STLGeometry :: STLGeometry() : edges(), edgesperpoint(), normals(), externaledges(), atlas(), chartmark(), lines(), outerchartspertrig(), vicinity(), markedtrigs(), markedsegs(), lineendpoints(), spiralpoints(), selectedmultiedge() { edgedata = new STLEdgeDataList(*this); externaledges.SetSize(0); Clear(); meshchart = 0; // initialize all ?? JS if (geomsearchtreeon) searchtree = new Box3dTree (GetBoundingBox().PMin() - Vec3d(1,1,1), GetBoundingBox().PMax() + Vec3d(1,1,1)); else searchtree = NULL; status = STL_GOOD; statustext = "Good Geometry"; smoothedges = NULL; } STLGeometry :: ~STLGeometry() { delete edgedata; } int STLGeometry :: GenerateMesh (Mesh*& mesh, int perfstepsstart, int perfstepsend, char* optstring) { return STLMeshingDummy (this, mesh, perfstepsstart, perfstepsend, optstring); } const Refinement & STLGeometry :: GetRefinement () const { return * new RefinementSTLGeometry (*this); } void STLGeometry :: STLInfo(double* data) { data[0] = GetNT(); Box<3> b = GetBoundingBox(); data[1] = b.PMin()(0); data[2] = b.PMax()(0); data[3] = b.PMin()(1); data[4] = b.PMax()(1); data[5] = b.PMin()(2); data[6] = b.PMax()(2); int i; int cons = 1; for (i = 1; i <= GetNT(); i++) { if (NONeighbourTrigs(i) != 3) {cons = 0;} } data[7] = cons; } void STLGeometry :: MarkNonSmoothNormals() { PrintFnStart("Mark Non-Smooth Normals"); int i,j; markedtrigs.SetSize(GetNT()); for (i = 1; i <= GetNT(); i++) { SetMarkedTrig(i, 0); } double dirtyangle = stlparam.yangle/180.*M_PI; int cnt = 0; int lp1,lp2; for (i = 1; i <= GetNT(); i++) { for (j = 1; j <= NONeighbourTrigs(i); j++) { if (GetAngle(i, NeighbourTrig(i,j)) > dirtyangle) { GetTriangle(i).GetNeighbourPoints(GetTriangle(NeighbourTrig(i,j)), lp1, lp2); if (!IsEdge(lp1,lp2)) { if (!IsMarkedTrig(i)) {SetMarkedTrig(i,1); cnt++;} } } } } PrintMessage(5,"marked ",cnt," non-smooth trig-normals"); } void STLGeometry :: SmoothNormals() { multithread.terminate = 0; // UseExternalEdges(); BuildEdges(); DenseMatrix m(3), hm(3); Vector rhs(3), sol(3), hv(3), hv2(3); Vec<3> ri; double wnb = stldoctor.smoothnormalsweight; // neigbour normal weight double wgeom = 1-wnb; // geometry normal weight // minimize // wgeom sum_T \sum ri \| ri^T (n - n_geom) \|^2 // + wnb sum_SE \| ri x (n - n_nb) \|^2 int i, j, k, l; int nt = GetNT(); PushStatusF("Smooth Normals"); //int testmode; for (i = 1; i <= nt; i++) { SetThreadPercent( 100.0 * (double)i / (double)nt); const STLTriangle & trig = GetTriangle (i); m = 0; rhs = 0; // normal of geometry: Vec<3> ngeom = trig.GeomNormal(points); ngeom.Normalize(); for (j = 1; j <= 3; j++) { int pi1 = trig.PNumMod (j); int pi2 = trig.PNumMod (j+1); // edge vector ri = GetPoint (pi2) - GetPoint (pi1); for (k = 0; k < 3; k++) for (l = 0; l < 3; l++) hm.Elem(k+1, l+1) = wgeom * ri(k) * ri(l); for (k = 0; k < 3; k++) hv(k) = ngeom(k); hm.Mult (hv, hv2); /* if (testmode) (*testout) << "add vec " << hv2 << endl << " add m " << hm << endl; */ rhs.Add (1, hv2); m += hm; int nbt = 0; int fp1,fp2; for (k = 1; k <= NONeighbourTrigs(i); k++) { trig.GetNeighbourPoints(GetTriangle(NeighbourTrig(i, k)),fp1,fp2); if (fp1 == pi1 && fp2 == pi2) { nbt = NeighbourTrig(i, k); } } if (!nbt) { cerr << "ERROR: stlgeom::Smoothnormals, nbt = 0" << endl; } // smoothed normal Vec<3> nnb = GetTriangle(nbt).Normal(); // neighbour normal nnb.Normalize(); if (!IsEdge(pi1,pi2)) { double lr2 = ri * ri; for (k = 0; k < 3; k++) { for (l = 0; l < k; l++) { hm.Elem(k+1, l+1) = -wnb * ri(k) * ri(l); hm.Elem(l+1, k+1) = -wnb * ri(k) * ri(l); } hm.Elem(k+1, k+1) = wnb * (lr2 - ri(k) * ri(k)); } for (k = 0; k < 3; k++) hv(k) = nnb(k); hm.Mult (hv, hv2); /* if (testmode) (*testout) << "add nb vec " << hv2 << endl << " add nb m " << hm << endl; */ rhs.Add (1, hv2); m += hm; } } m.Solve (rhs, sol); Vec3d newn(sol(0), sol(1), sol(2)); newn /= (newn.Length() + 1e-24); GetTriangle(i).SetNormal(newn); // setnormal (sol); } /* for (i = 1; i <= nt; i++) SetMarkedTrig(i, 0); int crloop; for (crloop = 1; crloop <= 3; crloop++) { // find critical: Array critpairs; for (i = 1; i <= nt; i++) { const STLTriangle & trig = GetTriangle (i); Vec3d ngeom = GetTriangleNormal (i); // trig.Normal(points); ngeom /= (ngeom.Length() + 1e-24); for (j = 1; j <= 3; j++) { int pi1 = trig.PNumMod (j); int pi2 = trig.PNumMod (j+1); int nbt = 0; int fp1,fp2; for (k = 1; k <= NONeighbourTrigs(i); k++) { trig.GetNeighbourPoints(GetTriangle(NeighbourTrig(i, k)),fp1,fp2); if (fp1 == pi1 && fp2 == pi2) { nbt = NeighbourTrig(i, k); } } if (!nbt) { cerr << "ERROR: stlgeom::Smoothnormals, nbt = 0" << endl; } Vec3d nnb = GetTriangleNormal(nbt); // neighbour normal nnb /= (nnb.Length() + 1e-24); if (!IsEdge(pi1,pi2)) { if (Angle (nnb, ngeom) > 150 * M_PI/180) { SetMarkedTrig(i, 1); SetMarkedTrig(nbt, 1); critpairs.Append (INDEX_2 (i, nbt)); } } } } if (!critpairs.Size()) { break; } if (critpairs.Size()) { Array friends; double area1 = 0, area2 = 0; for (i = 1; i <= critpairs.Size(); i++) { int tnr1 = critpairs.Get(i).I1(); int tnr2 = critpairs.Get(i).I2(); (*testout) << "t1 = " << tnr1 << ", t2 = " << tnr2 << " angle = " << Angle (GetTriangleNormal (tnr1), GetTriangleNormal (tnr2)) << endl; // who has more friends ? int side; area1 = 0; area2 = 0; for (side = 1; side <= 2; side++) { friends.SetSize (0); friends.Append ( (side == 1) ? tnr1 : tnr2); for (j = 1; j <= 3; j++) { int fsize = friends.Size(); for (k = 1; k <= fsize; k++) { int testtnr = friends.Get(k); Vec3d ntt = GetTriangleNormal(testtnr); ntt /= (ntt.Length() + 1e-24); for (l = 1; l <= NONeighbourTrigs(testtnr); l++) { int testnbnr = NeighbourTrig(testtnr, l); Vec3d nbt = GetTriangleNormal(testnbnr); nbt /= (nbt.Length() + 1e-24); if (Angle (nbt, ntt) < 15 * M_PI/180) { int ii; int found = 0; for (ii = 1; ii <= friends.Size(); ii++) { if (friends.Get(ii) == testnbnr) { found = 1; break; } } if (!found) friends.Append (testnbnr); } } } } // compute area: for (k = 1; k <= friends.Size(); k++) { double area = GetTriangle (friends.Get(k)).Area(points); if (side == 1) area1 += area; else area2 += area; } } (*testout) << "area1 = " << area1 << " area2 = " << area2 << endl; if (area1 < 0.1 * area2) { Vec3d n = GetTriangleNormal (tnr1); n *= -1; SetTriangleNormal(tnr1, n); } if (area2 < 0.1 * area1) { Vec3d n = GetTriangleNormal (tnr2); n *= -1; SetTriangleNormal(tnr2, n); } } } } */ calcedgedataanglesnew = 1; PopStatus(); } int STLGeometry :: AddEdge(int ap1, int ap2) { STLEdge e(ap1,ap2); e.SetLeftTrig(GetLeftTrig(ap1,ap2)); e.SetRightTrig(GetRightTrig(ap1,ap2)); return edges.Append(e); } void STLGeometry :: STLDoctorConfirmEdge() { StoreEdgeData(); if (GetSelectTrig() >= 1 && GetSelectTrig() <= GetNT() && GetNodeOfSelTrig()) { if (stldoctor.selectmode == 1) { int ap1 = GetTriangle(GetSelectTrig()).PNum(GetNodeOfSelTrig()); int ap2 = GetTriangle(GetSelectTrig()).PNumMod(GetNodeOfSelTrig()+1); edgedata->Elem(edgedata->GetEdgeNum(ap1,ap2)).SetStatus (ED_CONFIRMED); } else if (stldoctor.selectmode == 3 || stldoctor.selectmode == 4) { int i; for (i = 1; i <= selectedmultiedge.Size(); i++) { int ap1 = selectedmultiedge.Get(i).i1; int ap2 = selectedmultiedge.Get(i).i2; edgedata->Elem(edgedata->GetEdgeNum(ap1,ap2)).SetStatus (ED_CONFIRMED); } } } } void STLGeometry :: STLDoctorCandidateEdge() { StoreEdgeData(); if (GetSelectTrig() >= 1 && GetSelectTrig() <= GetNT() && GetNodeOfSelTrig()) { if (stldoctor.selectmode == 1) { int ap1 = GetTriangle(GetSelectTrig()).PNum(GetNodeOfSelTrig()); int ap2 = GetTriangle(GetSelectTrig()).PNumMod(GetNodeOfSelTrig()+1); edgedata->Elem(edgedata->GetEdgeNum(ap1,ap2)).SetStatus (ED_CANDIDATE); } else if (stldoctor.selectmode == 3 || stldoctor.selectmode == 4) { int i; for (i = 1; i <= selectedmultiedge.Size(); i++) { int ap1 = selectedmultiedge.Get(i).i1; int ap2 = selectedmultiedge.Get(i).i2; edgedata->Elem(edgedata->GetEdgeNum(ap1,ap2)).SetStatus (ED_CANDIDATE); } } } } void STLGeometry :: STLDoctorExcludeEdge() { StoreEdgeData(); if (GetSelectTrig() >= 1 && GetSelectTrig() <= GetNT() && GetNodeOfSelTrig()) { if (stldoctor.selectmode == 1) { int ap1 = GetTriangle(GetSelectTrig()).PNum(GetNodeOfSelTrig()); int ap2 = GetTriangle(GetSelectTrig()).PNumMod(GetNodeOfSelTrig()+1); edgedata->Elem(edgedata->GetEdgeNum(ap1,ap2)).SetStatus(ED_EXCLUDED); } else if (stldoctor.selectmode == 3 || stldoctor.selectmode == 4) { int i; for (i = 1; i <= selectedmultiedge.Size(); i++) { int ap1 = selectedmultiedge.Get(i).i1; int ap2 = selectedmultiedge.Get(i).i2; edgedata->Elem(edgedata->GetEdgeNum(ap1,ap2)).SetStatus(ED_EXCLUDED); } } } } void STLGeometry :: STLDoctorUndefinedEdge() { StoreEdgeData(); if (GetSelectTrig() >= 1 && GetSelectTrig() <= GetNT() && GetNodeOfSelTrig()) { if (stldoctor.selectmode == 1) { int ap1 = GetTriangle(GetSelectTrig()).PNum(GetNodeOfSelTrig()); int ap2 = GetTriangle(GetSelectTrig()).PNumMod(GetNodeOfSelTrig()+1); edgedata->Elem(edgedata->GetEdgeNum(ap1,ap2)).SetStatus(ED_UNDEFINED); } else if (stldoctor.selectmode == 3 || stldoctor.selectmode == 4) { int i; for (i = 1; i <= selectedmultiedge.Size(); i++) { int ap1 = selectedmultiedge.Get(i).i1; int ap2 = selectedmultiedge.Get(i).i2; edgedata->Elem(edgedata->GetEdgeNum(ap1,ap2)).SetStatus(ED_UNDEFINED); } } } } void STLGeometry :: STLDoctorSetAllUndefinedEdges() { edgedata->ResetAll(); } void STLGeometry :: STLDoctorEraseCandidateEdges() { StoreEdgeData(); edgedata->ChangeStatus(ED_CANDIDATE, ED_UNDEFINED); } void STLGeometry :: STLDoctorConfirmCandidateEdges() { StoreEdgeData(); edgedata->ChangeStatus(ED_CANDIDATE, ED_CONFIRMED); } void STLGeometry :: STLDoctorConfirmedToCandidateEdges() { StoreEdgeData(); edgedata->ChangeStatus(ED_CONFIRMED, ED_CANDIDATE); } void STLGeometry :: STLDoctorDirtyEdgesToCandidates() { StoreEdgeData(); } void STLGeometry :: STLDoctorLongLinesToCandidates() { StoreEdgeData(); } twoint STLGeometry :: GetNearestSelectedDefinedEdge() { Point<3> pestimate = Center(GetTriangle(GetSelectTrig()).center, GetPoint(GetTriangle(GetSelectTrig()).PNum(GetNodeOfSelTrig()))); //Point3d pestimate = GetTriangle(GetSelectTrig()).center; int i, j, en; Array vic; GetVicinity(GetSelectTrig(),4,vic); twoint fedg; fedg.i1 = 0; fedg.i2 = 0; double mindist = 1E50; double dist; Point<3> p; for (i = 1; i <= vic.Size(); i++) { const STLTriangle& t = GetTriangle(vic.Get(i)); for (j = 1; j <= 3; j++) { en = edgedata->GetEdgeNum(t.PNum(j),t.PNumMod(j+1)); if (edgedata->Get(en).GetStatus() != ED_UNDEFINED) { p = pestimate; dist = GetDistFromLine(GetPoint(t.PNum(j)),GetPoint(t.PNumMod(j+1)),p); if (dist < mindist) { mindist = dist; fedg.i1 = t.PNum(j); fedg.i2 = t.PNumMod(j+1); } } } } return fedg; } void STLGeometry :: BuildSelectedMultiEdge(twoint ep) { if (edgedata->Size() == 0 || !GetEPPSize()) { return; } selectedmultiedge.SetSize(0); int tenum = GetTopEdgeNum (ep.i1, ep.i2); if (edgedata->Get(tenum).GetStatus() == ED_UNDEFINED) { twoint epnew = GetNearestSelectedDefinedEdge(); if (epnew.i1) { ep = epnew; tenum = GetTopEdgeNum (ep.i1, ep.i2); } } selectedmultiedge.Append(twoint(ep)); if (edgedata->Get(tenum).GetStatus() == ED_UNDEFINED) { return; } edgedata->BuildLineWithEdge(ep.i1,ep.i2,selectedmultiedge); } void STLGeometry :: BuildSelectedEdge(twoint ep) { if (edgedata->Size() == 0 || !GetEPPSize()) { return; } selectedmultiedge.SetSize(0); selectedmultiedge.Append(twoint(ep)); } void STLGeometry :: BuildSelectedCluster(twoint ep) { if (edgedata->Size() == 0 || !GetEPPSize()) { return; } selectedmultiedge.SetSize(0); int tenum = GetTopEdgeNum (ep.i1, ep.i2); if (edgedata->Get(tenum).GetStatus() == ED_UNDEFINED) { twoint epnew = GetNearestSelectedDefinedEdge(); if (epnew.i1) { ep = epnew; tenum = GetTopEdgeNum (ep.i1, ep.i2); } } selectedmultiedge.Append(twoint(ep)); if (edgedata->Get(tenum).GetStatus() == ED_UNDEFINED) { return; } edgedata->BuildClusterWithEdge(ep.i1,ep.i2,selectedmultiedge); } void STLGeometry :: ImportEdges() { StoreEdgeData(); PrintMessage(5, "import edges from file 'edges.ng'"); ifstream fin("edges.ng"); int ne; fin >> ne; Array > eps; int i; Point<3> p; for (i = 1; i <= 2*ne; i++) { fin >> p(0); fin >> p(1); fin >> p(2); eps.Append(p); } AddEdges(eps); } void STLGeometry :: AddEdges(const Array >& eps) { int i; int ne = eps.Size()/2; Array epsi; Box<3> bb = GetBoundingBox(); bb.Increase(1); Point3dTree ptree (bb.PMin(), bb.PMax()); Array pintersect; double gtol = GetBoundingBox().Diam()/1.E10; Point<3> p; for (i = 1; i <= GetNP(); i++) { p = GetPoint(i); ptree.Insert (p, i); } int error = 0; for (i = 1; i <= 2*ne; i++) { p = eps.Get(i); Point3d pmin = p - Vec3d (gtol, gtol, gtol); Point3d pmax = p + Vec3d (gtol, gtol, gtol); ptree.GetIntersecting (pmin, pmax, pintersect); if (pintersect.Size() > 1) { PrintError("Found too much points in epsilon-dist"); error = 1; } else if (pintersect.Size() == 0) { error = 1; PrintError("edgepoint does not exist!"); PrintMessage(5,"p=",Point3d(eps.Get(i))); } else { epsi.Append(pintersect.Get(1)); } } if (error) return; int en; for (i = 1; i <= ne; i++) { if (epsi.Get(2*i-1) == epsi.Get(2*i)) {PrintError("Edge with zero length!");} else { en = edgedata->GetEdgeNum(epsi.Get(2*i-1),epsi.Get(2*i)); edgedata->Elem(en).SetStatus (ED_CONFIRMED); } } } void STLGeometry :: ImportExternalEdges(const char * filename) { //AVL edges!!!!!! ifstream inf (filename); char ch; //int cnt = 0; int records, units, i, j; PrintFnStart("Import edges from ",filename); const int flen=30; char filter[flen+1]; filter[flen] = 0; char buf[20]; Array importpoints; Array importlines; Array importpnums; while (inf.good()) { inf.get(ch); // (*testout) << cnt << ": " << ch << endl; for (i = 0; i < flen; i++) filter[i] = filter[i+1]; filter[flen-1] = ch; // (*testout) << filter << endl; if (strcmp (filter+flen-7, "RECORDS") == 0) { inf.get(ch); // '=' inf >> records; } if (strcmp (filter+flen-5, "UNITS") == 0) { inf.get(ch); // '=' inf >> units; } if (strcmp (filter+flen-17, "EDGE NODE NUMBERS") == 0) { int nodenr; importlines.SetSize (units); for (i = 1; i <= units; i++) { inf >> nodenr; importlines.Elem(i) = nodenr; // (*testout) << nodenr << endl; } } if (strcmp (filter+flen-23, "EDGE POINT COORD IN DIR") == 0) { int coord; inf >> coord; importpoints.SetSize (units); inf >> ch; inf.putback (ch); for (i = 1; i <= units; i++) { for (j = 0; j < 12; j++) inf.get (buf[j]); buf[12] = 0; importpoints.Elem(i).X(coord) = 1000 * atof (buf); } } } /* (*testout) << "lines: " << endl; for (i = 1; i <= importlines.Size(); i++) (*testout) << importlines.Get(i) << endl; (*testout) << "points: " << endl; for (i = 1; i <= importpoints.Size(); i++) (*testout) << importpoints.Get(i) << endl; */ importpnums.SetSize (importpoints.Size()); Box3d bb (GetBoundingBox().PMin() + Vec3d (-1,-1,-1), GetBoundingBox().PMax() + Vec3d (1, 1, 1)); Point3dTree ptree (bb.PMin(), bb.PMax()); PrintMessage(7,"stl - bb: ",bb.PMin(), " - ", bb.PMax()); Box3d ebb; ebb.SetPoint (importpoints.Get(1)); for (i = 1; i <= importpoints.Size(); i++) ebb.AddPoint (importpoints.Get(i)); PrintMessage(7,"edgep - bb: ", ebb.PMin(), " - ", ebb.PMax()); Array pintersect; double gtol = GetBoundingBox().Diam()/1.E6; for (i = 1; i <= GetNP(); i++) { Point3d p = GetPoint(i); // (*testout) << "stlpt: " << p << endl; ptree.Insert (p, i); } for (i = 1; i <= importpoints.Size(); i++) { Point3d p = importpoints.Get(i); Point3d pmin = p - Vec3d (gtol, gtol, gtol); Point3d pmax = p + Vec3d (gtol, gtol, gtol); ptree.GetIntersecting (pmin, pmax, pintersect); if (pintersect.Size() > 1) { importpnums.Elem(i) = 0; PrintError("Found too many points in epsilon-dist"); } else if (pintersect.Size() == 0) { importpnums.Elem(i) = 0; PrintError("Edgepoint does not exist!"); } else { importpnums.Elem(i) = pintersect.Get(1); } } // if (!error) { PrintMessage(7,"found all edge points in stl file"); StoreEdgeData(); int oldp = 0; for (i = 1; i <= importlines.Size(); i++) { int newp = importlines.Get(i); if (!importpnums.Get(abs(newp))) newp = 0; if (oldp && newp) { int en = edgedata->GetEdgeNum(importpnums.Get(oldp), importpnums.Get(abs(newp))); edgedata->Elem(en).SetStatus (ED_CONFIRMED); } if (newp < 0) oldp = 0; else oldp = newp; } } } void STLGeometry :: ExportEdges() { PrintFnStart("Save edges to file 'edges.ng'"); ofstream fout("edges.ng"); fout.precision(16); int n = edgedata->GetNConfEdges(); fout << n << endl; int i; for (i = 1; i <= edgedata->Size(); i++) { if (edgedata->Get(i).GetStatus() == ED_CONFIRMED) { const STLTopEdge & e = edgedata->Get(i); fout << GetPoint(e.PNum(1))(0) << " " << GetPoint(e.PNum(1))(1) << " " << GetPoint(e.PNum(1))(2) << endl; fout << GetPoint(e.PNum(2))(0) << " " << GetPoint(e.PNum(2))(1) << " " << GetPoint(e.PNum(2))(2) << endl; } } } void STLGeometry :: LoadEdgeData(const char* file) { StoreEdgeData(); PrintFnStart("Load edges from file '", file, "'"); ifstream fin(file); edgedata->Read(fin); // calcedgedataanglesnew = 1; } void STLGeometry :: SaveEdgeData(const char* file) { PrintFnStart("save edges to file '", file, "'"); ofstream fout(file); edgedata->Write(fout); } /* void STLGeometry :: SaveExternalEdges() { ofstream fout("externaledgesp3.ng"); fout.precision(16); int n = NOExternalEdges(); fout << n << endl; int i; for (i = 1; i <= n; i++) { twoint e = GetExternalEdge(i); fout << GetPoint(e.i1)(0) << " " << GetPoint(e.i1)(1) << " " << GetPoint(e.i1)(2) << endl; fout << GetPoint(e.i2)(0) << " " << GetPoint(e.i2)(1) << " " << GetPoint(e.i2)(2) << endl; } } */ void STLGeometry :: StoreExternalEdges() { storedexternaledges.SetSize(0); undoexternaledges = 1; int i; for (i = 1; i <= externaledges.Size(); i++) { storedexternaledges.Append(externaledges.Get(i)); } } void STLGeometry :: UndoExternalEdges() { if (!undoexternaledges) { PrintMessage(1, "undo not further possible!"); return; } RestoreExternalEdges(); undoexternaledges = 0; } void STLGeometry :: RestoreExternalEdges() { externaledges.SetSize(0); int i; for (i = 1; i <= storedexternaledges.Size(); i++) { externaledges.Append(storedexternaledges.Get(i)); } } void STLGeometry :: AddExternalEdgeAtSelected() { StoreExternalEdges(); if (GetSelectTrig() >= 1 && GetSelectTrig() <= GetNT()) { int ap1 = GetTriangle(GetSelectTrig()).PNum(GetNodeOfSelTrig()); int ap2 = GetTriangle(GetSelectTrig()).PNumMod(GetNodeOfSelTrig()+1); if (!IsExternalEdge(ap1,ap2)) {AddExternalEdge(ap1,ap2);} } } void STLGeometry :: AddClosedLinesToExternalEdges() { StoreExternalEdges(); int i, j; for (i = 1; i <= GetNLines(); i++) { STLLine* l = GetLine(i); if (l->StartP() == l->EndP()) { for (j = 1; j < l->NP(); j++) { int ap1 = l->PNum(j); int ap2 = l->PNum(j+1); if (!IsExternalEdge(ap1,ap2)) {AddExternalEdge(ap1,ap2);} } } } } void STLGeometry :: AddLongLinesToExternalEdges() { StoreExternalEdges(); double diamfact = stldoctor.dirtytrigfact; double diam = GetBoundingBox().Diam(); int i, j; for (i = 1; i <= GetNLines(); i++) { STLLine* l = GetLine(i); if (l->GetLength(points) >= diamfact*diam) { for (j = 1; j < l->NP(); j++) { int ap1 = l->PNum(j); int ap2 = l->PNum(j+1); if (!IsExternalEdge(ap1,ap2)) {AddExternalEdge(ap1,ap2);} } } } } void STLGeometry :: AddAllNotSingleLinesToExternalEdges() { StoreExternalEdges(); int i, j; for (i = 1; i <= GetNLines(); i++) { STLLine* l = GetLine(i); if (GetNEPP(l->StartP()) > 1 || GetNEPP(l->EndP()) > 1) { for (j = 1; j < l->NP(); j++) { int ap1 = l->PNum(j); int ap2 = l->PNum(j+1); if (!IsExternalEdge(ap1,ap2)) {AddExternalEdge(ap1,ap2);} } } } } void STLGeometry :: DeleteDirtyExternalEdges() { //delete single triangle edges and single edge-lines in clusters" StoreExternalEdges(); int i, j; for (i = 1; i <= GetNLines(); i++) { STLLine* l = GetLine(i); if (l->NP() <= 3 || (l->StartP() == l->EndP() && l->NP() == 4)) { for (j = 1; j < l->NP(); j++) { int ap1 = l->PNum(j); int ap2 = l->PNum(j+1); if (IsExternalEdge(ap1,ap2)) {DeleteExternalEdge(ap1,ap2);} } } } } void STLGeometry :: AddExternalEdgesFromGeomLine() { StoreExternalEdges(); if (GetSelectTrig() >= 1 && GetSelectTrig() <= GetNT()) { int ap1 = GetTriangle(GetSelectTrig()).PNum(GetNodeOfSelTrig()); int ap2 = GetTriangle(GetSelectTrig()).PNumMod(GetNodeOfSelTrig()+1); if (IsEdge(ap1,ap2)) { int edgenum = IsEdgeNum(ap1,ap2); if (!IsExternalEdge(ap1,ap2)) {AddExternalEdge(ap1,ap2);} int noend = 1; int startp = ap1; int laste = edgenum; int np1, np2; while (noend) { if (GetNEPP(startp) == 2) { if (GetEdgePP(startp,1) != laste) {laste = GetEdgePP(startp,1);} else {laste = GetEdgePP(startp,2);} np1 = GetEdge(laste).PNum(1); np2 = GetEdge(laste).PNum(2); if (!IsExternalEdge(np1, np2)) {AddExternalEdge(np1, np2);} else {noend = 0;} if (np1 != startp) {startp = np1;} else {startp = np2;} } else {noend = 0;} } startp = ap2; laste = edgenum; noend = 1; while (noend) { if (GetNEPP(startp) == 2) { if (GetEdgePP(startp,1) != laste) {laste = GetEdgePP(startp,1);} else {laste = GetEdgePP(startp,2);} np1 = GetEdge(laste).PNum(1); np2 = GetEdge(laste).PNum(2); if (!IsExternalEdge(np1, np2)) {AddExternalEdge(np1, np2);} else {noend = 0;} if (np1 != startp) {startp = np1;} else {startp = np2;} } else {noend = 0;} } } } } void STLGeometry :: ClearEdges() { edgesfound = 0; edges.SetSize(0); //edgedata->SetSize(0); // externaledges.SetSize(0); edgesperpoint.SetSize(0); undoexternaledges = 0; } void STLGeometry :: STLDoctorBuildEdges() { // if (!trigsconverted) {return;} ClearEdges(); meshlines.SetSize(0); FindEdgesFromAngles(); } void STLGeometry :: DeleteExternalEdgeAtSelected() { StoreExternalEdges(); if (GetSelectTrig() >= 1 && GetSelectTrig() <= GetNT()) { int ap1 = GetTriangle(GetSelectTrig()).PNum(GetNodeOfSelTrig()); int ap2 = GetTriangle(GetSelectTrig()).PNumMod(GetNodeOfSelTrig()+1); if (IsExternalEdge(ap1,ap2)) {DeleteExternalEdge(ap1,ap2);} } } void STLGeometry :: DeleteExternalEdgeInVicinity() { StoreExternalEdges(); if (!stldoctor.showvicinity || vicinity.Size() != GetNT()) {return;} int i, j, ap1, ap2; for (i = 1; i <= GetNT(); i++) { if (vicinity.Elem(i)) { for (j = 1; j <= 3; j++) { ap1 = GetTriangle(i).PNum(j); ap2 = GetTriangle(i).PNumMod(j+1); if (IsExternalEdge(ap1,ap2)) { DeleteExternalEdge(ap1,ap2); } } } } } void STLGeometry :: BuildExternalEdgesFromEdges() { StoreExternalEdges(); if (GetNE() == 0) {PrintWarning("Edges possibly not generated!");} int i; externaledges.SetSize(0); for (i = 1; i <= GetNE(); i++) { STLEdge e = GetEdge(i); AddExternalEdge(e.PNum(1), e.PNum(2)); } } void STLGeometry :: AddExternalEdge(int ap1, int ap2) { externaledges.Append(twoint(ap1,ap2)); } void STLGeometry :: DeleteExternalEdge(int ap1, int ap2) { int i; int found = 0; for (i = 1; i <= NOExternalEdges(); i++) { if ((GetExternalEdge(i).i1 == ap1 && GetExternalEdge(i).i2 == ap2) || (GetExternalEdge(i).i1 == ap2 && GetExternalEdge(i).i2 == ap1)) {found = 1;}; if (found && i < NOExternalEdges()) { externaledges.Elem(i) = externaledges.Get(i+1); } } if (!found) {PrintWarning("edge not found");} else { externaledges.SetSize(externaledges.Size()-1); } } int STLGeometry :: IsExternalEdge(int ap1, int ap2) { int i; for (i = 1; i <= NOExternalEdges(); i++) { if ((GetExternalEdge(i).i1 == ap1 && GetExternalEdge(i).i2 == ap2) || (GetExternalEdge(i).i1 == ap2 && GetExternalEdge(i).i2 == ap1)) {return 1;}; } return 0; } void STLGeometry :: DestroyDirtyTrigs() { PrintFnStart("Destroy dirty triangles"); PrintMessage(5,"original number of triangles=", GetNT()); //destroy every triangle with other than 3 neighbours; int changed = 1; int i, j, k; while (changed) { changed = 0; Clear(); for (i = 1; i <= GetNT(); i++) { int dirty = NONeighbourTrigs(i) < 3; for (j = 1; j <= 3; j++) { int pnum = GetTriangle(i).PNum(j); /* if (pnum == 1546) { // for (k = 1; k <= NOTrigsPerPoint(pnum); k++) } */ if (NOTrigsPerPoint(pnum) <= 2) dirty = 1; } int pi1 = GetTriangle(i).PNum(1); int pi2 = GetTriangle(i).PNum(2); int pi3 = GetTriangle(i).PNum(3); if (pi1 == pi2 || pi1 == pi3 || pi2 == pi3) { PrintMessage(5,"triangle with Volume 0: ", i, " nodes: ", pi1, ", ", pi2, ", ", pi3); dirty = 1; } if (dirty) { for (k = i+1; k <= GetNT(); k++) { trias.Elem(k-1) = trias.Get(k); // readtrias: not longer permanent, JS // readtrias.Elem(k-1) = readtrias.Get(k); } int size = GetNT(); trias.SetSize(size-1); // readtrias.SetSize(size-1); changed = 1; break; } } } FindNeighbourTrigs(); PrintMessage(5,"final number of triangles=", GetNT()); } void STLGeometry :: CalcNormalsFromGeometry() { int i; for (i = 1; i <= GetNT(); i++) { const STLTriangle & tr = GetTriangle(i); const Point3d& ap1 = GetPoint(tr.PNum(1)); const Point3d& ap2 = GetPoint(tr.PNum(2)); const Point3d& ap3 = GetPoint(tr.PNum(3)); Vec3d normal = Cross (ap2-ap1, ap3-ap1); if (normal.Length() != 0) { normal /= (normal.Length()); } GetTriangle(i).SetNormal(normal); } PrintMessage(5,"Normals calculated from geometry!!!"); calcedgedataanglesnew = 1; } void STLGeometry :: SetSelectTrig(int trig) { stldoctor.selecttrig = trig; } int STLGeometry :: GetSelectTrig() const { return stldoctor.selecttrig; } void STLGeometry :: SetNodeOfSelTrig(int n) { stldoctor.nodeofseltrig = n; } int STLGeometry :: GetNodeOfSelTrig() const { return stldoctor.nodeofseltrig; } void STLGeometry :: MoveSelectedPointToMiddle() { if (GetSelectTrig() >= 1 && GetSelectTrig() <= GetNT()) { int p = GetTriangle(GetSelectTrig()).PNum(GetNodeOfSelTrig()); Point<3> pm(0.,0.,0.); //Middlevector; Point<3> p0(0.,0.,0.); PrintMessage(5,"original point=", Point3d(GetPoint(p))); int i; int cnt = 0; for (i = 1; i <= trigsperpoint.EntrySize(p); i++) { const STLTriangle& tr = GetTriangle(trigsperpoint.Get(p,i)); int j; for (j = 1; j <= 3; j++) { if (tr.PNum(j) != p) { cnt++; pm(0) += GetPoint(tr.PNum(j))(0); pm(1) += GetPoint(tr.PNum(j))(1); pm(2) += GetPoint(tr.PNum(j))(2); } } } Point<3> origp = GetPoint(p); double fact = 0.2; SetPoint(p, p0 + fact*(1./(double)cnt)*(pm-p0)+(1.-fact)*(origp-p0)); PrintMessage(5,"middle point=", Point3d (GetPoint(p))); PrintMessage(5,"moved point ", Point3d (p)); } } void STLGeometry :: PrintSelectInfo() { //int trig = GetSelectTrig(); //int p = GetTriangle(trig).PNum(GetNodeOfSelTrig()); PrintMessage(1,"touch triangle ", GetSelectTrig() , ", local node ", GetNodeOfSelTrig() , " (=", GetTriangle(GetSelectTrig()).PNum(GetNodeOfSelTrig()), ")"); if (AtlasMade() && GetSelectTrig() >= 1 && GetSelectTrig() <= GetNT()) { PrintMessage(1," chartnum=",GetChartNr(GetSelectTrig())); /* PointBetween(Center(Center(GetPoint(GetTriangle(270).PNum(1)), GetPoint(GetTriangle(270).PNum(2))), GetPoint(GetTriangle(270).PNum(3))),270, Center(Center(GetPoint(GetTriangle(trig).PNum(1)), GetPoint(GetTriangle(trig).PNum(2))), GetPoint(GetTriangle(trig).PNum(3))),trig); */ //PointBetween(Point3d(5.7818, 7.52768, 4.14879),260,Point3d(6.80292, 6.55392, 4.70184),233); } } void STLGeometry :: ShowSelectedTrigChartnum() { int st = GetSelectTrig(); if (st >= 1 && st <= GetNT() && AtlasMade()) PrintMessage(1,"selected trig ", st, " has chartnumber ", GetChartNr(st)); } void STLGeometry :: ShowSelectedTrigCoords() { int st = GetSelectTrig(); /* //testing!!!! Array trigs; GetSortedTrianglesAroundPoint(GetTriangle(st).PNum(GetNodeOfSelTrig()),st,trigs); */ if (st >= 1 && st <= GetNT()) { PrintMessage(1, "coordinates of selected trig ", st, ":"); PrintMessage(1, " p1 = ", GetTriangle(st).PNum(1), " = ", Point3d (GetPoint(GetTriangle(st).PNum(1)))); PrintMessage(1, " p2 = ", GetTriangle(st).PNum(2), " = ", Point3d (GetPoint(GetTriangle(st).PNum(2)))); PrintMessage(1, " p3 = ", GetTriangle(st).PNum(3), " = ", Point3d (GetPoint(GetTriangle(st).PNum(3)))); } } void STLGeometry :: LoadMarkedTrigs() { PrintFnStart("load marked trigs from file 'markedtrigs.ng'"); ifstream fin("markedtrigs.ng"); int n; fin >> n; if (n != GetNT() || n == 0) {PrintError("Not a suitable marked-trig-file!"); return;} int i, m; for (i = 1; i <= n; i++) { fin >> m; SetMarkedTrig(i, m); } fin >> n; if (n != 0) { Point<3> ap1, ap2; for (i = 1; i <= n; i++) { fin >> ap1(0); fin >> ap1(1); fin >> ap1(2); fin >> ap2(0); fin >> ap2(1); fin >> ap2(2); AddMarkedSeg(ap1,ap2); } } } void STLGeometry :: SaveMarkedTrigs() { PrintFnStart("save marked trigs to file 'markedtrigs.ng'"); ofstream fout("markedtrigs.ng"); int n = GetNT(); fout << n << endl; int i; for (i = 1; i <= n; i++) { fout << IsMarkedTrig(i) << "\n"; } n = GetNMarkedSegs(); fout << n << endl; Point<3> ap1,ap2; for (i = 1; i <= n; i++) { GetMarkedSeg(i,ap1,ap2); fout << ap1(0) << " " << ap1(1) << " " << ap1(2) << " "; fout << ap2(0) << " " << ap2(1) << " " << ap2(2) << " " << "\n"; } } void STLGeometry :: NeighbourAnglesOfSelectedTrig() { int st = GetSelectTrig(); if (st >= 1 && st <= GetNT()) { int i; PrintMessage(1,"Angle to triangle ", st, ":"); for (i = 1; i <= NONeighbourTrigs(st); i++) { PrintMessage(1," triangle ", NeighbourTrig(st,i), ": angle = ", 180./M_PI*GetAngle(st, NeighbourTrig(st,i)), "°", ", calculated = ", 180./M_PI*Angle(GetTriangle(st).GeomNormal(points), GetTriangle(NeighbourTrig(st,i)).GeomNormal(points)), "°"); } } } void STLGeometry :: GetVicinity(int starttrig, int size, Array& vic) { if (starttrig == 0 || starttrig > GetNT()) {return;} Array vicarray; vicarray.SetSize(GetNT()); int i; for (i = 1; i <= vicarray.Size(); i++) { vicarray.Elem(i) = 0; } vicarray.Elem(starttrig) = 1; int j = 0,k; Array list1; list1.SetSize(0); Array list2; list2.SetSize(0); list1.Append(starttrig); while (j < size) { j++; for (i = 1; i <= list1.Size(); i++) { for (k = 1; k <= NONeighbourTrigs(i); k++) { int nbtrig = NeighbourTrig(list1.Get(i),k); if (nbtrig && vicarray.Get(nbtrig) == 0) { list2.Append(nbtrig); vicarray.Elem(nbtrig) = 1; } } } list1.SetSize(0); for (i = 1; i <= list2.Size(); i++) { list1.Append(list2.Get(i)); } list2.SetSize(0); } vic.SetSize(0); for (i = 1; i <= vicarray.Size(); i++) { if (vicarray.Get(i)) {vic.Append(i);} } } void STLGeometry :: CalcVicinity(int starttrig) { if (starttrig == 0 || starttrig > GetNT()) {return;} vicinity.SetSize(GetNT()); if (!stldoctor.showvicinity) {return;} int i; for (i = 1; i <= vicinity.Size(); i++) { vicinity.Elem(i) = 0; } vicinity.Elem(starttrig) = 1; int j = 0,k; Array list1; list1.SetSize(0); Array list2; list2.SetSize(0); list1.Append(starttrig); // int cnt = 1; while (j < stldoctor.vicinity) { j++; for (i = 1; i <= list1.Size(); i++) { for (k = 1; k <= NONeighbourTrigs(i); k++) { int nbtrig = NeighbourTrig(list1.Get(i),k); if (nbtrig && vicinity.Get(nbtrig) == 0) { list2.Append(nbtrig); vicinity.Elem(nbtrig) = 1; //cnt++; } } } list1.SetSize(0); for (i = 1; i <= list2.Size(); i++) { list1.Append(list2.Get(i)); } list2.SetSize(0); } } int STLGeometry :: Vicinity(int trig) const { if (trig <= vicinity.Size() && trig >=1) { return vicinity.Get(trig); } else {PrintSysError("In STLGeometry::Vicinity");} return 0; } void STLGeometry :: InitMarkedTrigs() { markedtrigs.SetSize(GetNT()); int i; for (i = 1; i <= GetNT(); i++) { SetMarkedTrig(i, 0); } } void STLGeometry :: MarkDirtyTrigs() { PrintFnStart("mark dirty trigs"); int i,j; markedtrigs.SetSize(GetNT()); for (i = 1; i <= GetNT(); i++) { SetMarkedTrig(i, 0); } int found; double dirtyangle = stlparam.yangle/2./180.*M_PI; int cnt = 0; for (i = 1; i <= GetNT(); i++) { found = 0; for (j = 1; j <= NONeighbourTrigs(i); j++) { if (GetAngle(i, NeighbourTrig(i,j)) > dirtyangle) { found++; } } if (found && GetTriangle(i).MinHeight(points) < stldoctor.dirtytrigfact*GetTriangle(i).MaxLength(points)) { SetMarkedTrig(i, 1); cnt++; } /* else if (found == 3) { SetMarkedTrig(i, 1); cnt++; } */ } PrintMessage(1, "marked ", cnt, " dirty trigs"); } void STLGeometry :: MarkTopErrorTrigs() { int cnt = 0; markedtrigs.SetSize(GetNT()); for (int i = 1; i <= GetNT(); i++) { const STLTriangle & trig = GetTriangle(i); SetMarkedTrig(i, trig.flags.toperror); if (trig.flags.toperror) cnt++; } PrintMessage(1,"marked ", cnt, " inconsistent triangles"); } double STLGeometry :: CalcTrigBadness(int i) { int j; double maxbadness = 0; int ap1, ap2; for (j = 1; j <= NONeighbourTrigs(i); j++) { GetTriangle(i).GetNeighbourPoints(GetTriangle(NeighbourTrig(i,j)), ap1, ap2); if (!IsEdge(ap1,ap2) && GetGeomAngle(i, NeighbourTrig(i,j)) > maxbadness) { maxbadness = GetGeomAngle(i, NeighbourTrig(i,j)); } } return maxbadness; } void STLGeometry :: GeomSmoothRevertedTrigs() { //double revertedangle = stldoctor.smoothangle/180.*M_PI; double fact = stldoctor.dirtytrigfact; MarkRevertedTrigs(); int i, j, k, l, p; for (i = 1; i <= GetNT(); i++) { if (IsMarkedTrig(i)) { for (j = 1; j <= 3; j++) { double origbadness = CalcTrigBadness(i); p = GetTriangle(i).PNum(j); Point<3> pm(0.,0.,0.); //Middlevector; Point<3> p0(0.,0.,0.); int cnt = 0; for (k = 1; k <= trigsperpoint.EntrySize(p); k++) { const STLTriangle& tr = GetTriangle(trigsperpoint.Get(p,k)); for (l = 1; l <= 3; l++) { if (tr.PNum(l) != p) { cnt++; pm(0) += GetPoint(tr.PNum(l))(0); pm(1) += GetPoint(tr.PNum(l))(1); pm(2) += GetPoint(tr.PNum(l))(2); } } } Point3d origp = GetPoint(p); Point3d newp = p0 + fact*(1./(double)cnt)*(pm-p0)+(1.-fact)*(origp-p0); SetPoint(p, newp); if (CalcTrigBadness(i) > 0.9*origbadness) {SetPoint(p,origp); PrintDot('f');} else {PrintDot('s');} } } } MarkRevertedTrigs(); } void STLGeometry :: MarkRevertedTrigs() { int i,j; if (edgesperpoint.Size() != GetNP()) {BuildEdges();} PrintFnStart("mark reverted trigs"); InitMarkedTrigs(); int found; double revertedangle = stldoctor.smoothangle/180.*M_PI; int cnt = 0; int ap1, ap2; for (i = 1; i <= GetNT(); i++) { found = 0; for (j = 1; j <= NONeighbourTrigs(i); j++) { GetTriangle(i).GetNeighbourPoints(GetTriangle(NeighbourTrig(i,j)), ap1, ap2); if (!IsEdge(ap1,ap2)) { if (GetGeomAngle(i, NeighbourTrig(i,j)) > revertedangle) { found = 1; break; } } } if (found) { SetMarkedTrig(i, 1); cnt++; } } PrintMessage(5, "found ", cnt, " reverted trigs"); } void STLGeometry :: SmoothDirtyTrigs() { PrintFnStart("smooth dirty trigs"); MarkDirtyTrigs(); int i,j; int changed = 1; int ap1, ap2; while (changed) { changed = 0; for (i = 1; i <= GetNT(); i++) { if (IsMarkedTrig(i)) { int foundtrig = 0; double maxlen = 0; // JS: darf normalvector nicht ueber kurze Seite erben maxlen = GetTriangle(i).MaxLength(GetPoints()) / 2.1; //JG: bei flachem dreieck auch kurze Seite for (j = 1; j <= NONeighbourTrigs(i); j++) { if (!IsMarkedTrig(NeighbourTrig(i,j))) { GetTriangle(i).GetNeighbourPoints(GetTriangle(NeighbourTrig(i,j)),ap1,ap2); if (Dist(GetPoint(ap1),GetPoint(ap2)) >= maxlen) { foundtrig = NeighbourTrig(i,j); maxlen = Dist(GetPoint(ap1),GetPoint(ap2)); } } } if (foundtrig) { GetTriangle(i).SetNormal(GetTriangle(foundtrig).Normal()); changed = 1; SetMarkedTrig(i,0); } } } } calcedgedataanglesnew = 1; MarkDirtyTrigs(); int cnt = 0; for (i = 1; i <= GetNT(); i++) { if (IsMarkedTrig(i)) {cnt++;} } PrintMessage(5,"NO marked dirty trigs=", cnt); } int STLGeometry :: IsMarkedTrig(int trig) const { if (trig <= markedtrigs.Size() && trig >=1) { return markedtrigs.Get(trig); } else {PrintSysError("In STLGeometry::IsMarkedTrig");} return 0; } void STLGeometry :: SetMarkedTrig(int trig, int num) { if (trig <= markedtrigs.Size() && trig >=1) { markedtrigs.Elem(trig) = num; } else {PrintSysError("In STLGeometry::SetMarkedTrig");} } void STLGeometry :: Clear() { PrintFnStart("Clear"); surfacemeshed = 0; surfaceoptimized = 0; volumemeshed = 0; selectedmultiedge.SetSize(0); meshlines.SetSize(0); // neighbourtrigs.SetSize(0); outerchartspertrig.SetSize(0); atlas.SetSize(0); ClearMarkedSegs(); ClearSpiralPoints(); ClearLineEndPoints(); SetSelectTrig(0); SetNodeOfSelTrig(1); facecnt = 0; SetThreadPercent(100.); ClearEdges(); } double STLGeometry :: Area() { double ar = 0; int i; for (i = 1; i <= GetNT(); i++) { ar += GetTriangle(i).Area(points); } return ar; } double STLGeometry :: GetAngle(int t1, int t2) { return Angle(GetTriangle(t1).Normal(),GetTriangle(t2).Normal()); } double STLGeometry :: GetGeomAngle(int t1, int t2) { Vec3d n1 = GetTriangle(t1).GeomNormal(points); Vec3d n2 = GetTriangle(t2).GeomNormal(points); return Angle(n1,n2); } void STLGeometry :: InitSTLGeometry(const Array & readtrias) { PrintFnStart("Init STL Geometry"); STLTopology::InitSTLGeometry(readtrias); int i, k; //const double geometry_tol_fact = 1E8; //distances lower than max_box_size/tol are ignored int np = GetNP(); PrintMessage(5,"NO points= ", GetNP()); normals.SetSize(GetNP()); Array normal_cnt(GetNP()); // counts number of added normals in a point for (i = 1; i <= np; i++) { normal_cnt.Elem(i) = 0; normals.Elem(i) = Vec3d (0,0,0); } for(i = 1; i <= GetNT(); i++) { // STLReadTriangle t = GetReadTriangle(i); // STLTriangle st; Vec<3> n = GetTriangle(i).Normal (); for (k = 1; k <= 3; k++) { int pi = GetTriangle(i).PNum(k); normal_cnt.Elem(pi)++; SetNormal(pi, GetNormal(pi) + n); } } //normalize the normals for (i = 1; i <= GetNP(); i++) { SetNormal(i,1./(double)normal_cnt.Get(i)*GetNormal(i)); } trigsconverted = 1; vicinity.SetSize(GetNT()); markedtrigs.SetSize(GetNT()); for (i = 1; i <= GetNT(); i++) { markedtrigs.Elem(i) = 0; vicinity.Elem(i) = 1; } ha_points.SetSize(GetNP()); for (i = 1; i <= GetNP(); i++) ha_points.Elem(i) = 0; calcedgedataanglesnew = 0; edgedatastored = 0; edgedata->Clear(); if (GetStatus() == STL_ERROR) return; CalcEdgeData(); CalcEdgeDataAngles(); ClearLineEndPoints(); CheckGeometryOverlapping(); } void STLGeometry :: TopologyChanged() { calcedgedataanglesnew = 1; } int STLGeometry :: CheckGeometryOverlapping() { int i, j, k; Box<3> geombox = GetBoundingBox(); Point<3> pmin = geombox.PMin(); Point<3> pmax = geombox.PMax(); Box3dTree setree(pmin, pmax); Array inters; int oltrigs = 0; markedtrigs.SetSize(GetNT()); for (i = 1; i <= GetNT(); i++) SetMarkedTrig(i, 0); for (i = 1; i <= GetNT(); i++) { const STLTriangle & tri = GetTriangle(i); Point<3> tpmin = tri.box.PMin(); Point<3> tpmax = tri.box.PMax(); Vec<3> diag = tpmax - tpmin; tpmax = tpmax + 0.001 * diag; tpmin = tpmin - 0.001 * diag; setree.Insert (tpmin, tpmax, i); } for (i = 1; i <= GetNT(); i++) { const STLTriangle & tri = GetTriangle(i); Point<3> tpmin = tri.box.PMin(); Point<3> tpmax = tri.box.PMax(); setree.GetIntersecting (tpmin, tpmax, inters); for (j = 1; j <= inters.Size(); j++) { const STLTriangle & tri2 = GetTriangle(inters.Get(j)); const Point<3> *trip1[3], *trip2[3]; Point<3> hptri1[3], hptri2[3]; /* for (k = 1; k <= 3; k++) { trip1[k-1] = &GetPoint (tri.PNum(k)); trip2[k-1] = &GetPoint (tri2.PNum(k)); } */ for (k = 0; k < 3; k++) { hptri1[k] = GetPoint (tri[k]); hptri2[k] = GetPoint (tri2[k]); trip1[k] = &hptri1[k]; trip2[k] = &hptri2[k]; } if (IntersectTriangleTriangle (&trip1[0], &trip2[0])) { oltrigs++; PrintMessage(5,"Intersecting Triangles: trig ",i," with ",inters.Get(j),"!"); SetMarkedTrig(i, 1); SetMarkedTrig(inters.Get(j), 1); } } } PrintMessage(3,"Check Geometry Overlapping: overlapping triangles = ",oltrigs); return oltrigs; } /* void STLGeometry :: InitSTLGeometry() { STLTopology::InitSTLGeometry(); int i, j, k; const double geometry_tol_fact = 1E8; //distances lower than max_box_size/tol are ignored trias.SetSize(0); points.SetSize(0); normals.SetSize(0); Array normal_cnt; // counts number of added normals in a point Box3d bb (GetBoundingBox().PMin() + Vec3d (-1,-1,-1), GetBoundingBox().PMax() + Vec3d (1, 1, 1)); Point3dTree pointtree (bb.PMin(), bb.PMax()); Array pintersect; double gtol = GetBoundingBox().CalcDiam()/geometry_tol_fact; for(i = 1; i <= GetReadNT(); i++) { //if (i%500==499) {(*mycout) << (double)i/(double)GetReadNT()*100. << "%" << endl;} STLReadTriangle t = GetReadTriangle(i); STLTriangle st; Vec3d n = t.normal; for (k = 0; k < 3; k++) { Point3d p = t.pts[k]; Point3d pmin = p - Vec3d (gtol, gtol, gtol); Point3d pmax = p + Vec3d (gtol, gtol, gtol); pointtree.GetIntersecting (pmin, pmax, pintersect); if (pintersect.Size() > 1) (*mycout) << "found too much " << char(7) << endl; int foundpos = 0; if (pintersect.Size()) foundpos = pintersect.Get(1); if (foundpos) { normal_cnt[foundpos]++; SetNormal(foundpos,GetNormal(foundpos)+n); // (*testout) << "found p " << p << endl; } else { foundpos = AddPoint(p); AddNormal(n); normal_cnt.Append(1); pointtree.Insert (p, foundpos); } //(*mycout) << "foundpos=" << foundpos << endl; st.pts[k] = foundpos; } if ( (st.pts[0] == st.pts[1]) || (st.pts[0] == st.pts[2]) || (st.pts[1] == st.pts[2]) ) { (*mycout) << "ERROR: STL Triangle degenerated" << endl; } else { // do not add ? js AddTriangle(st); } //(*mycout) << "TRIG" << i << " = " << st << endl; } //normal the normals for (i = 1; i <= GetNP(); i++) { SetNormal(i,1./(double)normal_cnt[i]*GetNormal(i)); } trigsconverted = 1; vicinity.SetSize(GetNT()); markedtrigs.SetSize(GetNT()); for (i = 1; i <= GetNT(); i++) { markedtrigs.Elem(i) = 0; vicinity.Elem(i) = 1; } ha_points.SetSize(GetNP()); for (i = 1; i <= GetNP(); i++) ha_points.Elem(i) = 0; calcedgedataanglesnew = 0; edgedatastored = 0; edgedata->Clear(); CalcEdgeData(); CalcEdgeDataAngles(); ClearLineEndPoints(); (*mycout) << "done" << endl; } */ void STLGeometry :: SetLineEndPoint(int pn) { if (pn <1 || pn > lineendpoints.Size()) {PrintSysError("Illegal pnum in SetLineEndPoint!!!"); return; } lineendpoints.Elem(pn) = 1; } int STLGeometry :: IsLineEndPoint(int pn) { // return 0; if (pn <1 || pn > lineendpoints.Size()) {PrintSysError("Illegal pnum in IsLineEndPoint!!!"); return 0;} return lineendpoints.Get(pn); } void STLGeometry :: ClearLineEndPoints() { lineendpoints.SetSize(GetNP()); int i; for (i = 1; i <= GetNP(); i++) { lineendpoints.Elem(i) = 0; } } int STLGeometry :: IsEdge(int ap1, int ap2) { int i,j; for (i = 1; i <= GetNEPP(ap1); i++) { for (j = 1; j <= GetNEPP(ap2); j++) { if (GetEdgePP(ap1,i) == GetEdgePP(ap2,j)) {return 1;} } } return 0; } int STLGeometry :: IsEdgeNum(int ap1, int ap2) { int i,j; for (i = 1; i <= GetNEPP(ap1); i++) { for (j = 1; j <= GetNEPP(ap2); j++) { if (GetEdgePP(ap1,i) == GetEdgePP(ap2,j)) {return GetEdgePP(ap1,i);} } } return 0; } void STLGeometry :: BuildEdges() { //PrintFnStart("build edges"); edges.SetSize(0); meshlines.SetSize(0); FindEdgesFromAngles(); } void STLGeometry :: UseExternalEdges() { int i; for (i = 1; i <= NOExternalEdges(); i++) { AddEdge(GetExternalEdge(i).i1,GetExternalEdge(i).i2); } //BuildEdgesPerPointy(); } void STLGeometry :: UndoEdgeChange() { if (edgedatastored) { RestoreEdgeData(); } else { PrintWarning("no edge undo possible"); } } void STLGeometry :: StoreEdgeData() { // edgedata_store = *edgedata; edgedata->Store(); edgedatastored = 1; // put stlgeom-edgedata to stltopology edgedata /* int i; for (i = 1; i <= GetNTE(); i++) { const STLTopEdge & topedge = GetTopEdge (i); int ednum = edgedata->GetEdgeNum (topedge.PNum(1), topedge.PNum(2)); topedges.Elem(i).SetStatus (edgedata->Get (ednum).status); } */ } void STLGeometry :: RestoreEdgeData() { // *edgedata = edgedata_store; edgedata->Restore(); edgedatastored=0; } void STLGeometry :: CalcEdgeData() { PushStatus("Calc Edge Data"); int np1, np2; int i; int ecnt = 0; edgedata->SetSize(GetNT()/2*3); for (i = 1; i <= GetNT(); i++) { SetThreadPercent((double)i/(double)GetNT()*100.); const STLTriangle & t1 = GetTriangle(i); for (int j = 1; j <= NONeighbourTrigs(i); j++) { int nbti = NeighbourTrig(i,j); if (nbti > i) { const STLTriangle & t2 = GetTriangle(nbti); if (t1.IsNeighbourFrom(t2)) { ecnt++; if (ecnt > edgedata->Size()) {PrintError("In Calc edge data, illegal geometry");} t1.GetNeighbourPoints(t2,np1,np2); /* ang = GetAngle(i,nbti); if (ang < -M_PI) {ang += 2*M_PI;}*/ // edgedata->Add(STLEdgeData(0, np1, np2, i, nbti),ecnt); edgedata->Elem(ecnt).SetStatus(ED_UNDEFINED); // edgedata->Elem(ecnt).top = this; // edgedata->Elem(ecnt).topedgenr = GetTopEdgeNum (np1, np2); } } } } //BuildEdgesPerPoint(); PopStatus(); } void STLGeometry :: CalcEdgeDataAngles() { PrintMessage(5,"calc edge data angles"); int i; for (i = 1; i <= GetNTE(); i++) { STLTopEdge & edge = GetTopEdge (i); double cosang = GetTriangle(edge.TrigNum(1)).Normal() * GetTriangle(edge.TrigNum(2)).Normal(); edge.SetCosAngle (cosang); } for (i = 1; i <= edgedata->Size(); i++) { /* const STLEdgeData& e = edgedata->Get(i); ang = GetAngle(e.lt,e.rt); if (ang < -M_PI) {ang += 2*M_PI;} edgedata->Elem(i).angle = fabs(ang); */ } } void STLGeometry :: FindEdgesFromAngles() { // PrintFnStart("find edges from angles"); double min_edge_angle = stlparam.yangle/180.*M_PI; double cont_min_edge_angle = stlparam.contyangle/180.*M_PI; double cos_min_edge_angle = cos (min_edge_angle); double cos_cont_min_edge_angle = cos (cont_min_edge_angle); if (calcedgedataanglesnew) {CalcEdgeDataAngles(); calcedgedataanglesnew = 0;} int i; for (i = 1; i <= edgedata->Size(); i++) { STLTopEdge & sed = edgedata->Elem(i); if (sed.GetStatus() == ED_CANDIDATE || sed.GetStatus() == ED_UNDEFINED) { if (sed.CosAngle() <= cos_min_edge_angle) { sed.SetStatus (ED_CANDIDATE); } else { sed.SetStatus(ED_UNDEFINED); } } } if (stlparam.contyangle < stlparam.yangle) { int changed = 1; int its = 0; while (changed && stlparam.contyangle < stlparam.yangle) { its++; //(*mycout) << "." << flush; changed = 0; for (i = 1; i <= edgedata->Size(); i++) { STLTopEdge & sed = edgedata->Elem(i); if (sed.CosAngle() <= cos_cont_min_edge_angle && sed.GetStatus() == ED_UNDEFINED && (edgedata->GetNConfCandEPP(sed.PNum(1)) == 1 || edgedata->GetNConfCandEPP(sed.PNum(2)) == 1)) { changed = 1; sed.SetStatus (ED_CANDIDATE); } } } } int confcand = 0; if (edgedata->GetNConfEdges() == 0) { confcand = 1; } for (i = 1; i <= edgedata->Size(); i++) { STLTopEdge & sed = edgedata->Elem(i); if (sed.GetStatus() == ED_CONFIRMED || (sed.GetStatus() == ED_CANDIDATE && confcand)) { STLEdge se(sed.PNum(1),sed.PNum(2)); se.SetLeftTrig(sed.TrigNum(1)); se.SetRightTrig(sed.TrigNum(2)); AddEdge(se); } } BuildEdgesPerPoint(); //(*mycout) << "its for continued angle = " << its << endl; PrintMessage(5,"built ", GetNE(), " edges with yellow angle = ", stlparam.yangle, " degree"); } /* void STLGeometry :: FindEdgesFromAngles() { double yangle = stlparam.yangle; char * savetask = multithread.task; multithread.task = "find edges"; const double min_edge_angle = yangle/180.*M_PI; int np1, np2; double ang; int i; //(*mycout) << "area=" << Area() << endl; for (i = 1; i <= GetNT(); i++) { multithread.percent = (double)i/(double)GetReadNT()*100.; const STLTriangle & t1 = GetTriangle(i); //NeighbourTrigs(nt,i); for (int j = 1; j <= NONeighbourTrigs(i); j++) { int nbti = NeighbourTrig(i,j); if (nbti > i) { const STLTriangle & t2 = GetTriangle(nbti); if (t1.IsNeighbourFrom(t2)) { ang = GetAngle(i,nbti); if (ang < -M_PI*0.5) {ang += 2*M_PI;} t1.GetNeighbourPoints(t2,np1,np2); if (fabs(ang) >= min_edge_angle) { STLEdge se(np1,np2); se.SetLeftTrig(i); se.SetRightTrig(nbti); AddEdge(se); } } } } } (*mycout) << "added " << GetNE() << " edges" << endl; //BuildEdgesPerPoint(); multithread.percent = 100.; multithread.task = savetask; } */ void STLGeometry :: BuildEdgesPerPoint() { //cout << "*** build edges per point" << endl; edgesperpoint.SetSize(GetNP()); //add edges to points int i; for (i = 1; i <= GetNE(); i++) { //(*mycout) << "EDGE " << GetEdge(i).PNum(1) << " - " << GetEdge(i).PNum(2) << endl; for (int j = 1; j <= 2; j++) { AddEdgePP(GetEdge(i).PNum(j),i); } } } void STLGeometry :: AddFaceEdges() { PrintFnStart("Add starting edges for faces"); //für Kugel eine STLLine hinzufügen (Vorteil: verfeinerbar, unabhängig von Auflösung der Geometrie!!!): //Grenze von 1. gefundener chart Array edgecnt; Array chartindex; edgecnt.SetSize(GetNOFaces()); chartindex.SetSize(GetNOFaces()); int i,j; for (i = 1; i <= GetNOFaces(); i++) { edgecnt.Elem(i) = 0; chartindex.Elem(i) = 0; } for (i = 1; i <= GetNT(); i++) { int fn = GetTriangle(i).GetFaceNum(); if (!chartindex.Get(fn)) {chartindex.Elem(fn) = GetChartNr(i);} for (j = 1; j <= 3; j++) { edgecnt.Elem(fn) += GetNEPP(GetTriangle(i).PNum(j)); } } for (i = 1; i <= GetNOFaces(); i++) { if (!edgecnt.Get(i)) {PrintMessage(5,"Face", i, " has no edge!");} } int changed = 0; int k, ap1, ap2; for (i = 1; i <= GetNOFaces(); i++) { if (!edgecnt.Get(i)) { const STLChart& c = GetChart(chartindex.Get(i)); for (j = 1; j <= c.GetNChartT(); j++) { const STLTriangle& t1 = GetTriangle(c.GetChartTrig(j)); for (k = 1; k <= 3; k++) { int nt = NeighbourTrig(c.GetChartTrig(j),k); if (GetChartNr(nt) != chartindex.Get(i)) { t1.GetNeighbourPoints(GetTriangle(nt),ap1,ap2); AddEdge(ap1,ap2); changed = 1; } } } } } if (changed) BuildEdgesPerPoint(); } void STLGeometry :: LinkEdges() { PushStatusF("Link Edges"); PrintMessage(5,"have now ", GetNE(), " edges with yellow angle = ", stlparam.yangle, " degree"); int i; lines.SetSize(0); int starte(0); int edgecnt = 0; int found; int rev(0); //indicates, that edge is inserted reverse //worked edges Array we(GetNE()); //setlineendpoints; wenn 180°, dann keine endpunkte //nur punkte mit 2 edges kommen in frage, da bei mehr oder weniger punkten ohnehin ein meshpoint hinkommt Vec3d v1,v2; double cos_eca = cos(stlparam.edgecornerangle/180.*M_PI); int ecnt = 0; int lp1, lp2; if (stlparam.edgecornerangle < 180) { for (i = 1; i <= GetNP(); i++) { if (GetNEPP(i) == 2) { if (GetEdge(GetEdgePP(i,1)).PNum(2) == GetEdge(GetEdgePP(i,2)).PNum(1) || GetEdge(GetEdgePP(i,1)).PNum(1) == GetEdge(GetEdgePP(i,2)).PNum(2)) { lp1 = 1; lp2 = 2; } else { lp1 = 2; lp2 = 1; } v1 = Vec3d(GetPoint(GetEdge(GetEdgePP(i,1)).PNum(1)), GetPoint(GetEdge(GetEdgePP(i,1)).PNum(2))); v2 = Vec3d(GetPoint(GetEdge(GetEdgePP(i,2)).PNum(lp1)), GetPoint(GetEdge(GetEdgePP(i,2)).PNum(lp2))); if ((v1*v2)/sqrt(v1.Length2()*v2.Length2()) < cos_eca) { //(*testout) << "add edgepoint " << i << endl; SetLineEndPoint(i); ecnt++; } } } } PrintMessage(5, "added ", ecnt, " mesh_points due to edge corner angle (", stlparam.edgecornerangle, " degree)"); for (i = 1; i <= GetNE(); i++) {we.Elem(i) = 0;} while(edgecnt < GetNE()) { SetThreadPercent((double)edgecnt/(double)GetNE()*100.); STLLine* line = new STLLine(this); //find start edge int j = 1; found = 0; //try second time, if only rings are left!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! int second = 0; //find a starting edge at point with 1 or more than 2 edges or at lineendpoint while (!found && j<=GetNE()) { if (!we.Get(j)) { if (GetNEPP(GetEdge(j).PNum(1)) != 2 || IsLineEndPoint(GetEdge(j).PNum(1))) { starte = j; found = 1; rev = 0; } else if (GetNEPP(GetEdge(j).PNum(2)) != 2 || IsLineEndPoint(GetEdge(j).PNum(2))) { starte = j; found = 1; rev = 1; } else if (second) { starte = j; found = 1; rev = 0; //0 or 1 are possible } } j++; if (!second && j == GetNE()) {second = 1; j = 1;} } if (!found) {PrintSysError("No starting edge found, edgecnt=", edgecnt, ", GETNE=", GetNE());} line->AddPoint(GetEdge(starte).PNum(1+rev)); line->AddPoint(GetEdge(starte).PNum(2-rev)); if (!rev) { line->AddLeftTrig(GetEdge(starte).LeftTrig()); line->AddRightTrig(GetEdge(starte).RightTrig()); } else { line->AddLeftTrig(GetEdge(starte).RightTrig()); line->AddRightTrig(GetEdge(starte).LeftTrig()); } edgecnt++; we.Elem(starte) = 1; //add segments to line as long as segments other than starting edge are found or lineendpoint is reached found = 1; int other; while(found) { found = 0; int fp = GetEdge(starte).PNum(2-rev); if (GetNEPP(fp) == 2 && !IsLineEndPoint(fp)) { //find the "other" edge of point fp other = 0; if (GetEdgePP(fp,1) == starte) {other = 1;} starte = GetEdgePP(fp,1+other); //falls ring -> aufhoeren !!!!!!!!!!! if (!we.Elem(starte)) { found = 1; rev = 0; if (GetEdge(starte).PNum(2) == fp) {rev = 1;} else if (GetEdge(starte).PNum(1) != fp) {PrintSysError("In Link Edges!");} line->AddPoint(GetEdge(starte).PNum(2-rev)); if (!rev) { line->AddLeftTrig(GetEdge(starte).LeftTrig()); line->AddRightTrig(GetEdge(starte).RightTrig()); } else { line->AddLeftTrig(GetEdge(starte).RightTrig()); line->AddRightTrig(GetEdge(starte).LeftTrig()); } edgecnt++; we.Elem(starte) = 1; } } } AddLine(line); } PrintMessage(5,"number of lines generated = ", GetNLines()); //check, which lines must have at least one midpoint INDEX_2_HASHTABLE lineht(GetNLines()+1); for (i = 1; i <= GetNLines(); i++) { if (GetLine(i)->StartP() == GetLine(i)->EndP()) { GetLine(i)->DoSplit(); } } for (i = 1; i <= GetNLines(); i++) { INDEX_2 lineep (GetLine(i)->StartP(),GetLine(i)->EndP()); lineep.Sort(); if (lineht.Used (lineep)) { GetLine(i)->DoSplit(); int other = lineht.Get(lineep); GetLine(other)->DoSplit(); } else { lineht.Set (lineep, i); } } for (i = 1; i <= GetNLines(); i++) { STLLine* line = GetLine(i); for (int ii = 1; ii <= line->GetNS(); ii++) { int ap1, ap2; line->GetSeg(ii,ap1,ap2); // (*mycout) << "SEG " << p1 << " - " << p2 << endl; } } PopStatus(); } int STLGeometry :: GetNOBodys() { int markedtrigs1 = 0; int starttrig = 1; int i, k, nnt; int bodycnt = 0; Array bodynum(GetNT()); for (i = 1; i <= GetNT(); i++) bodynum.Elem(i)=0; while (markedtrigs1 < GetNT()) { for (i = starttrig; i <= GetNT(); i++) { if (!bodynum.Get(i)) { starttrig = i; break; } } //add all triangles around starttriangle, which is reachable without going over an edge Array todolist; Array nextlist; bodycnt++; markedtrigs1++; bodynum.Elem(starttrig) = bodycnt; todolist.Append(starttrig); while(todolist.Size()) { for (i = 1; i <= todolist.Size(); i++) { //const STLTriangle& tt = GetTriangle(todolist.Get(i)); for (k = 1; k <= NONeighbourTrigs(todolist.Get(i)); k++) { nnt = NeighbourTrig(todolist.Get(i),k); if (!bodynum.Get(nnt)) { nextlist.Append(nnt); bodynum.Elem(nnt) = bodycnt; markedtrigs1++; } } } todolist.SetSize(0); for (i = 1; i <= nextlist.Size(); i++) { todolist.Append(nextlist.Get(i)); } nextlist.SetSize(0); } } PrintMessage(3, "Geometry has ", bodycnt, " separated bodys"); return bodycnt; } void STLGeometry :: CalcFaceNums() { int markedtrigs1 = 0; int starttrig(0); int laststarttrig = 1; int i, k, nnt; facecnt = 0; for (i = 1; i <= GetNT(); i++) GetTriangle(i).SetFaceNum(0); while (markedtrigs1 < GetNT()) { for (i = laststarttrig; i <= GetNT(); i++) { if (!GetTriangle(i).GetFaceNum()) { starttrig = i; laststarttrig = i; break; } } //add all triangles around starttriangle, which is reachable without going over an edge Array todolist; Array nextlist; facecnt++; markedtrigs1++; GetTriangle(starttrig).SetFaceNum(facecnt); todolist.Append(starttrig); int ap1, ap2; while(todolist.Size()) { for (i = 1; i <= todolist.Size(); i++) { const STLTriangle& tt = GetTriangle(todolist.Get(i)); for (k = 1; k <= NONeighbourTrigs(todolist.Get(i)); k++) { nnt = NeighbourTrig(todolist.Get(i),k); STLTriangle& nt = GetTriangle(nnt); if (!nt.GetFaceNum()) { tt.GetNeighbourPoints(nt,ap1,ap2); if (!IsEdge(ap1,ap2)) { nextlist.Append(nnt); nt.SetFaceNum(facecnt); markedtrigs1++; } } } } todolist.SetSize(0); for (i = 1; i <= nextlist.Size(); i++) { todolist.Append(nextlist.Get(i)); } nextlist.SetSize(0); } } GetNOBodys(); PrintMessage(3,"generated ", facecnt, " faces"); } void STLGeometry :: ClearSpiralPoints() { spiralpoints.SetSize(GetNP()); int i; for (i = 1; i <= spiralpoints.Size(); i++) { spiralpoints.Elem(i) = 0; } } void STLGeometry :: BuildSmoothEdges () { if (smoothedges) delete smoothedges; smoothedges = new INDEX_2_HASHTABLE (GetNE()/10 + 1); // Jack: Ok ? // UseExternalEdges(); PushStatusF("Build Smooth Edges"); int i, j;//, k, l; int nt = GetNT(); Vec3d ng1, ng2; for (i = 1; i <= nt; i++) { if (multithread.terminate) {PopStatus();return;} SetThreadPercent(100.0 * (double)i / (double)nt); const STLTriangle & trig = GetTriangle (i); ng1 = trig.GeomNormal(points); ng1 /= (ng1.Length() + 1e-24); for (j = 1; j <= 3; j++) { int nbt = NeighbourTrig (i, j); ng2 = GetTriangle(nbt).GeomNormal(points); ng2 /= (ng2.Length() + 1e-24); int pi1, pi2; trig.GetNeighbourPoints(GetTriangle(nbt), pi1, pi2); if (!IsEdge(pi1,pi2)) { if (ng1 * ng2 < 0) { PrintMessage(7,"smoothedge found"); INDEX_2 i2(pi1, pi2); i2.Sort(); smoothedges->Set (i2, 1); } } } } PopStatus(); } int STLGeometry :: IsSmoothEdge (int pi1, int pi2) const { if (!smoothedges) return 0; INDEX_2 i2(pi1, pi2); i2.Sort(); return smoothedges->Used (i2); } //function is not used now int IsInArray(int n, const Array& ia) { int i; for (i = 1; i <= ia.Size(); i++) { if (ia.Get(i) == n) {return 1;} } return 0; } void STLGeometry :: AddConeAndSpiralEdges() { PrintMessage(5,"have now ", GetNE(), " edges with yellow angle = ", stlparam.yangle, " degree"); PrintFnStart("AddConeAndSpiralEdges"); int i,j,k,n; // int changed = 0; //check edges, where inner chart and no outer chart come together without an edge int np1, np2, nt; int cnt = 0; for (i = 1; i <= GetNOCharts(); i++) { STLChart& chart = GetChart(i); for (j = 1; j <= chart.GetNChartT(); j++) { int t = chart.GetChartTrig(j); const STLTriangle& tt = GetTriangle(t); for (k = 1; k <= 3; k++) { nt = NeighbourTrig(t,k); if (GetChartNr(nt) != i && !TrigIsInOC(nt,i)) { tt.GetNeighbourPoints(GetTriangle(nt),np1,np2); if (!IsEdge(np1,np2)) { STLEdge se(np1,np2); se.SetLeftTrig(t); se.SetRightTrig(nt); int edgenum = AddEdge(se); AddEdgePP(np1,edgenum); AddEdgePP(np2,edgenum); //changed = 1; PrintWarning("Found a spiral like structure: chart=", i, ", trig=", t, ", p1=", np1, ", p2=", np2); cnt++; } } } } } PrintMessage(5, "found ", cnt, " spiral like structures"); PrintMessage(5, "added ", cnt, " edges due to spiral like structures"); cnt = 0; int edgecnt = 0; Array trigsaroundp; Array chartpointchecked; //gets number of chart, if in this chart already checked chartpointchecked.SetSize(GetNP()); for (i = 1; i <= GetNP(); i++) { chartpointchecked.Elem(i) = 0; } int onoc, notonoc, tpp, pn; int ap1, ap2, tn1, tn2, l, problem; if (!stldoctor.conecheck) {PrintWarning("++++++++++++ \ncone checking deactivated by user!!!!!\n+++++++++++++++"); return ;} PushStatus("Find Critical Points"); int addedges = 0; for (i = 1; i <= GetNOCharts(); i++) { SetThreadPercent((double)i/(double)GetNOCharts()*100.); if (multithread.terminate) {PopStatus();return;} STLChart& chart = GetChart(i); for (j = 1; j <= chart.GetNChartT(); j++) { int t = chart.GetChartTrig(j); const STLTriangle& tt = GetTriangle(t); for (k = 1; k <= 3; k++) { pn = tt.PNum(k); if (chartpointchecked.Get(pn) == i) {continue;} int checkpoint = 0; for (n = 1; n <= trigsperpoint.EntrySize(pn); n++) { if (trigsperpoint.Get(pn,n) != t && GetChartNr(trigsperpoint.Get(pn,n)) != i && !TrigIsInOC(trigsperpoint.Get(pn,n),i)) {checkpoint = 1;}; } if (checkpoint) { chartpointchecked.Elem(pn) = i; int worked = 0; int spworked = 0; GetSortedTrianglesAroundPoint(pn,t,trigsaroundp); trigsaroundp.Append(t); problem = 0; for (l = 2; l <= trigsaroundp.Size()-1; l++) { tn1 = trigsaroundp.Get(l-1); tn2 = trigsaroundp.Get(l); const STLTriangle& t1 = GetTriangle(tn1); const STLTriangle& t2 = GetTriangle(tn2); t1.GetNeighbourPoints(t2, ap1, ap2); if (IsEdge(ap1,ap2)) break; if (GetChartNr(tn2) != i && !TrigIsInOC(tn2,i)) {problem = 1;} } if (problem) { for (l = 2; l <= trigsaroundp.Size()-1; l++) { tn1 = trigsaroundp.Get(l-1); tn2 = trigsaroundp.Get(l); const STLTriangle& t1 = GetTriangle(tn1); const STLTriangle& t2 = GetTriangle(tn2); t1.GetNeighbourPoints(t2, ap1, ap2); if (IsEdge(ap1,ap2)) break; if ((GetChartNr(tn1) == i && GetChartNr(tn2) != i && TrigIsInOC(tn2,i)) || (GetChartNr(tn2) == i && GetChartNr(tn1) != i && TrigIsInOC(tn1,i))) { if (addedges || !GetNEPP(pn)) { STLEdge se(ap1,ap2); se.SetLeftTrig(tn1); se.SetRightTrig(tn2); int edgenum = AddEdge(se); AddEdgePP(ap1,edgenum); AddEdgePP(ap2,edgenum); edgecnt++; } if (!addedges && !GetSpiralPoint(pn)) { SetSpiralPoint(pn); spworked = 1; } worked = 1; } } } //backwards: problem = 0; for (l = trigsaroundp.Size()-1; l >= 2; l--) { tn1 = trigsaroundp.Get(l+1); tn2 = trigsaroundp.Get(l); const STLTriangle& t1 = GetTriangle(tn1); const STLTriangle& t2 = GetTriangle(tn2); t1.GetNeighbourPoints(t2, ap1, ap2); if (IsEdge(ap1,ap2)) break; if (GetChartNr(tn2) != i && !TrigIsInOC(tn2,i)) {problem = 1;} } if (problem) for (l = trigsaroundp.Size()-1; l >= 2; l--) { tn1 = trigsaroundp.Get(l+1); tn2 = trigsaroundp.Get(l); const STLTriangle& t1 = GetTriangle(tn1); const STLTriangle& t2 = GetTriangle(tn2); t1.GetNeighbourPoints(t2, ap1, ap2); if (IsEdge(ap1,ap2)) break; if ((GetChartNr(tn1) == i && GetChartNr(tn2) != i && TrigIsInOC(tn2,i)) || (GetChartNr(tn2) == i && GetChartNr(tn1) != i && TrigIsInOC(tn1,i))) { if (addedges || !GetNEPP(pn)) { STLEdge se(ap1,ap2); se.SetLeftTrig(tn1); se.SetRightTrig(tn2); int edgenum = AddEdge(se); AddEdgePP(ap1,edgenum); AddEdgePP(ap2,edgenum); edgecnt++; } if (!addedges && !GetSpiralPoint(pn)) { SetSpiralPoint(pn); spworked = 1; //if (GetNEPP(pn) == 0) {(*mycout) << "ERROR: spiralpoint with no edge found!" << endl;} } worked = 1; } } if (worked) { //(*testout) << "set edgepoint due to spirals: pn=" << i << endl; SetLineEndPoint(pn); } if (spworked) { /* (*mycout) << "Warning: Critical Point " << tt.PNum(k) << "( chart " << i << ", trig " << t << ") has been neutralized!!!" << endl; */ cnt++; } // markedpoints.Elem(tt.PNum(k)) = 1; } } } } PrintMessage(5, "found ", cnt, " critical points!"); PrintMessage(5, "added ", edgecnt, " edges due to critical points!"); PopStatus(); //search points where inner chart and outer chart and "no chart" trig come together at edge-point PrintMessage(7,"search for special chart points"); for (i = 1; i <= GetNOCharts(); i++) { STLChart& chart = GetChart(i); for (j = 1; j <= chart.GetNChartT(); j++) { int t = chart.GetChartTrig(j); const STLTriangle& tt = GetTriangle(t); for (k = 1; k <= 3; k++) { pn = tt.PNum(k); if (GetNEPP(pn) == 2) { onoc = 0; notonoc = 0; for (n = 1; n <= trigsperpoint.EntrySize(pn); n++) { tpp = trigsperpoint.Get(pn,n); if (tpp != t && GetChartNr(tpp) != i) { if (TrigIsInOC(tpp,i)) {onoc = 1;} if (!TrigIsInOC(tpp,i)) {notonoc = 1;} } } if (onoc && notonoc && !IsLineEndPoint(pn)) { GetSortedTrianglesAroundPoint(pn,t,trigsaroundp); int here = 1; //we start on this side of edge, !here = there int thereOC = 0; int thereNotOC = 0; for (l = 2; l <= trigsaroundp.Size(); l++) { GetTriangle(trigsaroundp.Get(l-1)). GetNeighbourPoints(GetTriangle(trigsaroundp.Get(l)), ap1, ap2); if (IsEdge(ap1,ap2)) {here = (here+1)%2;} if (!here && TrigIsInOC(trigsaroundp.Get(l),i)) {thereOC = 1;} if (!here && !TrigIsInOC(trigsaroundp.Get(l),i)) {thereNotOC = 1;} } if (thereOC && thereNotOC) { //(*mycout) << "Special OCICnotC - point " << pn << " found!" << endl; //(*testout) << "set edgepoint due to spirals: pn=" << i << endl; SetLineEndPoint(pn); } } } } } } PrintMessage(5,"have now ", GetNE(), " edges with yellow angle = ", stlparam.yangle, " degree"); } //get trigs at a point, started with starttrig, then every left void STLGeometry :: GetSortedTrianglesAroundPoint(int p, int starttrig, Array& trigs) { int acttrig = starttrig; trigs.SetAllocSize(trigsperpoint.EntrySize(p)); trigs.SetSize(0); trigs.Append(acttrig); int i, j, t, ap1, ap2, locindex1(0), locindex2(0); //(*mycout) << "trigs around point " << p << endl; int end = 0; while (!end) { const STLTriangle& at = GetTriangle(acttrig); for (i = 1; i <= trigsperpoint.EntrySize(p); i++) { t = trigsperpoint.Get(p,i); const STLTriangle& nt = GetTriangle(t); if (at.IsNeighbourFrom(nt)) { at.GetNeighbourPoints(nt, ap1, ap2); if (ap2 == p) {Swap(ap1,ap2);} if (ap1 != p) {PrintSysError("In GetSortedTrianglesAroundPoint!!!");} for (j = 1; j <= 3; j++) { if (at.PNum(j) == ap1) {locindex1 = j;}; if (at.PNum(j) == ap2) {locindex2 = j;}; } if ((locindex2+1)%3+1 == locindex1) { if (t != starttrig) { trigs.Append(t); // (*mycout) << "trig " << t << endl; acttrig = t; } else { end = 1; } break; } } } } } /* int STLGeometry :: NeighbourTrig(int trig, int nr) const { return neighbourtrigs.Get(trig,nr); } */ void STLGeometry :: SmoothGeometry () { int i, j, k; double maxerr0, maxerr; for (i = 1; i <= GetNP(); i++) { if (GetNEPP(i)) continue; maxerr0 = 0; for (j = 1; j <= NOTrigsPerPoint(i); j++) { int tnum = TrigPerPoint(i, j); double err = Angle (GetTriangle(tnum).Normal (), GetTriangle(tnum).GeomNormal(GetPoints())); if (err > maxerr0) maxerr0 = err; } Point3d pi = GetPoint (i); if (maxerr0 < 1.1) continue; // about 60 degree maxerr0 /= 2; // should be at least halfen for (k = 1; k <= NOTrigsPerPoint(i); k++) { const STLTriangle & trig = GetTriangle (TrigPerPoint (i, k)); Point3d c = Center(GetPoint (trig.PNum(1)), GetPoint (trig.PNum(2)), GetPoint (trig.PNum(3))); Point3d np = pi + 0.1 * (c - pi); SetPoint (i, np); maxerr = 0; for (j = 1; j <= NOTrigsPerPoint(i); j++) { int tnum = TrigPerPoint(i, j); double err = Angle (GetTriangle(tnum).Normal (), GetTriangle(tnum).GeomNormal(GetPoints())); if (err > maxerr) maxerr = err; } if (maxerr < maxerr0) { pi = np; } } SetPoint (i, pi); } } } netgen-4.9.13/libsrc/stlgeom/stlgeommesh.cpp0000644000175000001440000011334111240003503015757 00000000000000//20.11.1999 second part of stlgeom.cc, mainly mesh functions #include #include #include #include #include #include "stlgeom.hpp" namespace netgen { int EdgeUsed(int p1, int p2, Array& edges, INDEX_2_HASHTABLE& hashtab) { if (p1 > p2) {swap (p1,p2);} if (hashtab.Used(INDEX_2(p1,p2))) {return hashtab.Get(INDEX_2(p1,p2));} return 0; } Point<3> STLGeometry :: PointBetween(const Point<3> & ap1, int t1, const Point<3> & ap2, int t2) { //funktioniert nicht in allen Fällen! PrintWarning("Point between"); ClearMarkedSegs(); InitMarkedTrigs(); SetMarkedTrig(t1,1); SetMarkedTrig(t2,1); TABLE edgepoints; TABLE edgepointdists; TABLE edgepointorigines; TABLE edgepointoriginps; Array edgetrigs; Array edgepointnums; Array edgetriglocinds; int size = 3*GetNT(); INDEX_2_HASHTABLE hashtab(size); int divisions = 10; edgepoints.SetSize(size); edgepointdists.SetSize(size); edgepointorigines.SetSize(size); edgepointoriginps.SetSize(size); edgetrigs.SetSize(size); edgepointnums.SetSize(size); edgetriglocinds.SetSize(size); Array edgelist1; Array edgelist2; edgelist1.SetSize(0); edgelist2.SetSize(0); int i, j, k, l, m; int edgecnt = 0; //first triangle: for (i = 1; i <= 3; i++) { int ptn1 = GetTriangle(t1).PNum(i); int ptn2 = GetTriangle(t1).PNumMod(i+1); if (ptn1 > ptn2) {swap(ptn1,ptn2);} Point3d pt1 = GetPoint(ptn1); Point3d pt2 = GetPoint(ptn2); edgecnt++; edgetrigs.Elem(edgecnt) = t1; edgepointnums.Elem(edgecnt) = INDEX_2(ptn1,ptn2); hashtab.Set(edgepointnums.Get(edgecnt),edgecnt); edgetriglocinds.Elem(edgecnt) = i; edgelist1.Append(edgecnt); for (j = 1; j <= divisions; j++) { double lfact = (double)j/(double)divisions; Point3d pbtw(lfact*pt1.X()+(1.-lfact)*pt2.X(), lfact*pt1.Y()+(1.-lfact)*pt2.Y(), lfact*pt1.Z()+(1.-lfact)*pt2.Z()); //AddMarkedSeg(ap1,pbtw); edgepoints.Add1(edgecnt,pbtw); edgepointdists.Add1(edgecnt,Dist(pbtw,ap1)); edgepointorigines.Add1(edgecnt,0); edgepointoriginps.Add1(edgecnt,0); } } int finished = 0; int endpointorigine = 0; int endpointoriginp = 0; double endpointmindist = 1E50; int maxsize = 0; while (!finished) { finished = 1; if (edgelist1.Size() > maxsize) {maxsize = edgelist1.Size();} for (i = 1; i <= edgelist1.Size(); i++) { int en = edgelist1.Get(i); int trig = edgetrigs.Get(en); int edgenum = edgetriglocinds.Get(en); int tn = NeighbourTrigSorted(trig,edgenum); if (tn != t2) { for (k = 1; k <= 3; k++) { int pnt1 = GetTriangle(tn).PNum(k); int pnt2 = GetTriangle(tn).PNumMod(k+1); if (pnt1 > pnt2) {swap(pnt1,pnt2);} Point3d pt1 = GetPoint(pnt1); Point3d pt2 = GetPoint(pnt2); //AddMarkedSeg(pt1,pt2); //if (!(pnt1 == ep1 && pnt2 == ep2)) // { int edgeused = 0; edgenum = EdgeUsed(pnt1, pnt2, edgepointnums, hashtab); if (edgenum != en) { if (edgenum != 0) {edgeused = 1;} else { edgecnt++; edgenum = edgecnt; edgetrigs.Elem(edgenum) = tn; edgepointnums.Elem(edgenum) = INDEX_2(pnt1,pnt2); hashtab.Set(edgepointnums.Get(edgenum),edgenum); edgetriglocinds.Elem(edgenum) = k; } if (edgenum > size || edgenum == 0) {PrintSysError("edgenum = ", edgenum);} double minofmindist = 1E50; int changed = 0; for (l = 1; l <= divisions; l++) { double lfact = (double)l/(double)divisions; Point3d pbtw(lfact*pt1.X()+(1.-lfact)*pt2.X(), lfact*pt1.Y()+(1.-lfact)*pt2.Y(), lfact*pt1.Z()+(1.-lfact)*pt2.Z()); double mindist = 1E50; int index=0; for (m = 1; m <= divisions; m++) { const Point3d& p = edgepoints.Get(en,m); if (Dist(pbtw,p) + edgepointdists.Get(en,m) < mindist) {mindist = Dist(pbtw,p) + edgepointdists.Get(en,m); index = m;} } //if (mindist < endpointmindist) {finished = 0;} if (mindist < minofmindist) {minofmindist = mindist;} if (!edgeused) { //AddMarkedSeg(pbtw,edgepoints.Get(en,index)); edgepoints.Add1(edgenum,pbtw); edgepointdists.Add1(edgenum,mindist); edgepointorigines.Add1(edgenum,en); edgepointoriginps.Add1(edgenum,index); changed = 1; } else { if (mindist < edgepointdists.Get(edgenum,l)) { edgepointdists.Set(edgenum,l,mindist); edgepointorigines.Set(edgenum,l,en); edgepointoriginps.Set(edgenum,l,index); changed = 1; } } } if (minofmindist < endpointmindist-1E-10 && changed) { finished = 0; edgelist2.Append(edgenum); } } } } else { double mindist = 1E50; int index(0); for (m = 1; m <= divisions; m++) { const Point3d& p = edgepoints.Get(en,m); if (Dist(ap2,p) + edgepointdists.Get(en,m) < mindist) {mindist = Dist(ap2,p) + edgepointdists.Get(en,m); index = m;} } if (mindist < endpointmindist) { endpointorigine = en; endpointoriginp = index; endpointmindist = mindist; } } } edgelist1.SetSize(0); for (i = 1; i <= edgelist2.Size(); i++) { edgelist1.Append(edgelist2.Get(i)); } } if (!endpointorigine) {PrintSysError("No connection found!");} Array plist; plist.Append(ap2); int laste = endpointorigine; int lastp = endpointoriginp; int lle, llp; while (laste) { plist.Append(edgepoints.Get(laste,lastp)); lle = laste; llp = lastp; laste = edgepointorigines.Get(lle,llp); lastp = edgepointoriginps.Get(lle,llp); } plist.Append(ap1); for (i = 1; i <= plist.Size()-1; i++) { AddMarkedSeg(plist.Get(i),plist.Get(i+1)); } PrintMessage(5,"PointBetween: complexity=", maxsize); Point3d pm; double dist = 0; int found = 0; for (i = 1; i <= plist.Size()-1; i++) { dist += Dist(plist.Get(i),plist.Get(i+1)); if (dist > endpointmindist*0.5) { double segl = Dist(plist.Get(i), plist.Get(i+1)); double d = dist - endpointmindist * 0.5; pm = Point3d(d/segl*plist.Get(i).X() + (1.-d/segl)*plist.Get(i+1).X(), d/segl*plist.Get(i).Y() + (1.-d/segl)*plist.Get(i+1).Y(), d/segl*plist.Get(i).Z() + (1.-d/segl)*plist.Get(i+1).Z()); found = 1; break; } } if (!found) {PrintWarning("Problem in PointBetween"); pm = Center(ap1,ap2);} AddMarkedSeg(pm, Point3d(0.,0.,0.)); return pm; } void STLGeometry :: PrepareSurfaceMeshing() { meshchart = -1; //clear no old chart meshcharttrigs.SetSize(GetNT()); int i; for (i = 1; i <= GetNT(); i++) {meshcharttrigs.Elem(i) = 0;} } void STLGeometry::GetMeshChartBoundary (Array & apoints, Array & points3d, Array & alines, double h) { int i, j; twoint seg, newseg; int zone; Point<2> p2; const STLChart& chart = GetChart(meshchart); for (i = 1; i <= chart.GetNOLimit(); i++) { seg = chart.GetOLimit(i); INDEX_2 i2; for (j = 1; j <= 2; j++) { int pi = (j == 1) ? seg.i1 : seg.i2; int lpi; if (ha_points.Get(pi) == 0) { const Point<3> & p3d = GetPoint (pi); Point<2> p2d; points3d.Append (p3d); ToPlane(p3d, 0, p2d, h, zone, 0); apoints.Append (p2d); lpi = apoints.Size(); ha_points.Elem(pi) = lpi; } else lpi = ha_points.Get(pi); i2.I(j) = lpi; } alines.Append (i2); /* seg = chart.GetOLimit(i); psize = points.Size(); newseg.i1 = psize+1; newseg.i2 = psize+2; ToPlane(GetPoint(seg.i1), 0, p2, h, zone, 0); points.Append(p2); points3d.Append (GetPoint(seg.i1)); ToPlane(GetPoint(seg.i2), 0, p2, h, zone, 0); points.Append(p2); points3d.Append (GetPoint(seg.i2)); lines.Append (INDEX_2 (points.Size()-1, points.Size())); */ } for (i = 1; i <= chart.GetNOLimit(); i++) { seg = chart.GetOLimit(i); ha_points.Elem(seg.i1) = 0; ha_points.Elem(seg.i2) = 0; } } void STLGeometry :: DefineTangentialPlane (const Point<3> & ap1, const Point<3> & ap2, int trig) { p1 = ap1; //save for ToPlane, in data of STLGeometry class Point<3> p2 = ap2; //only locally used meshchart = GetChartNr(trig); if (usechartnormal) meshtrignv = GetChart(meshchart).GetNormal(); else meshtrignv = GetTriangle(trig).Normal(); //meshtrignv = GetTriangle(trig).Normal(points); meshtrignv /= meshtrignv.Length(); GetTriangle(trig).ProjectInPlain(points, meshtrignv, p2); ez = meshtrignv; ez /= ez.Length(); ex = p2 - p1; ex -= (ex * ez) * ez; ex /= ex.Length(); ey = Cross (ez, ex); } void STLGeometry :: SelectChartOfTriangle (int trignum) { meshchart = GetChartNr(trignum); meshtrignv = GetTriangle(trignum).Normal(); } void STLGeometry :: SelectChartOfPoint (const Point<3> & p) { int i, ii; Array trigsinbox; Box<3> box(p,p); box.Increase (1e-6); GetTrianglesInBox (box, trigsinbox); // for (i = 1; i <= GetNT(); i++) for (ii = 1; ii <= trigsinbox.Size(); ii++) { i = trigsinbox.Get(ii); Point<3> hp = p; if (GetTriangle(i).GetNearestPoint(points, hp) <= 1E-8) { SelectChartOfTriangle (i); break; } } return; } void STLGeometry :: ToPlane (const Point<3> & locpoint, int * trigs, Point<2> & plainpoint, double h, int& zone, int checkchart) { if (checkchart) { //check if locpoint lies on actual chart: zone = 0; // Point3d p; int i = 1; const STLChart& chart = GetChart(meshchart); int foundinchart = 0; const double range = 1e-6; //1e-4 old if (trigs) { int * htrigs = trigs; while (*htrigs) { if (TrigIsInOC (*htrigs, meshchart)) { foundinchart = 1; break; } htrigs++; } } else { Array trigsinbox; if (!geomsearchtreeon) { //alter chart-tree Box<3> box(locpoint, locpoint); box.Increase (range); chart.GetTrianglesInBox (box.PMin(), box.PMax(), trigsinbox); } else { Array trigsinbox2; Box<3> box(locpoint, locpoint); box.Increase (range); GetTrianglesInBox (box, trigsinbox2); for (i = 1; i <= trigsinbox2.Size(); i++) { if (TrigIsInOC(trigsinbox2.Get(i),meshchart)) {trigsinbox.Append(trigsinbox2.Get(i));} } } for (i = 1; i <= trigsinbox.Size(); i++) { Point<3> p = locpoint; if (GetTriangle(trigsinbox.Get(i)).GetNearestPoint(points, p) <= 1E-8) { foundinchart = 1; break; } } } //do not use this point (but do correct projection (joachim) if (!foundinchart) { zone = -1; // plainpoint.X() = 11111; plainpoint.Y() = 11111; return; } } else { zone = 0; } //transform in plane Vec<3> p1p = locpoint - p1; plainpoint(0) = (p1p * ex) / h; plainpoint(1) = (p1p * ey) / h; } int STLGeometry :: FromPlane (const Point<2> & plainpoint, Point<3> & locpoint, double h) { Point2d plainpoint2 (plainpoint); plainpoint2.X() *= h; plainpoint2.Y() *= h; Vec3d p1p = plainpoint2.X() * ex + plainpoint2.Y() * ey; locpoint = p1 + p1p; int rv = Project(locpoint); if (!rv) {return 1;} //project nicht gegangen return 0; } int lasttrig; int STLGeometry :: LastTrig() const {return lasttrig;}; //project normal to tangential plane int STLGeometry :: Project(Point<3> & p3d) const { Point<3> p, pf; int i, j; int fi = 0; int cnt = 0; int different = 0; const double lamtol = 1e-6; const STLChart& chart = GetChart(meshchart); int nt = chart.GetNT(); QuadraticFunction3d quadfun(p3d, meshtrignv); /* Vec3d hv = meshtrignv; hv /= hv.Length(); Vec3d t1, t2; hv.GetNormal (t1); Cross (hv, t1, t2); */ for (j = 1; j <= nt; j++) { i = chart.GetTrig(j); const Point<3> & c = GetTriangle(i).center; /* double d1 = t1 * (c-p3d); double d2 = t2 * (c-p3d); */ /* if (d1 * d1 + d2 * d2 > sqr (GetTriangle(i).rad)) continue; */ if (quadfun.Eval(c) > sqr (GetTriangle(i).rad)) continue; p = p3d; Vec<3> lam; int err = GetTriangle(i).ProjectInPlain(points, meshtrignv, p, lam); int inside = (err == 0 && lam(0) > -lamtol && lam(1) > -lamtol && (1-lam(0)-lam(1)) > -lamtol); /* p = p3d; GetTriangle(i).ProjectInPlain(points, meshtrignv, p); if (GetTriangle(i).PointInside(points, p)) */ if (inside) { if (cnt != 0) { if (Dist2(p,pf)>=1E-16) { // (*testout) << "ERROR: found two points to project which are different" << endl; //(*testout) << "p=" << p << ", pf=" << pf << endl; different = 1; } } pf = p; fi = i; cnt++; } if (inside) break; } // if (cnt == 2) {(*testout) << "WARNING: found 2 triangles to project" << endl;} //if (cnt == 3) {(*testout) << "WARNING: found 3 triangles to project" << endl;} //if (cnt > 3) {(*testout) << "WARNING: found more than 3 triangles to project" << endl;} if (fi != 0) {lasttrig = fi;} if (fi != 0 && !different) {p3d = pf; return fi;} // (*testout) << "WARNING: Project failed" << endl; return 0; } //project normal to tangential plane int STLGeometry :: ProjectOnWholeSurface(Point<3> & p3d) const { Point<3> p, pf; int i; int fi = 0; int cnt = 0; int different = 0; const double lamtol = 1e-6; for (i = 1; i <= GetNT(); i++) { p = p3d; Vec<3> lam; int err = GetTriangle(i).ProjectInPlain(points, meshtrignv, p, lam); int inside = (err == 0 && lam(0) > -lamtol && lam(1) > -lamtol && (1-lam(0)-lam(1)) > -lamtol); /* p = p3d; GetTriangle(i).ProjectInPlain(points, meshtrignv, p); if (GetTriangle(i).PointInside(points, p)) */ if (inside) { if (cnt != 0) { if (Dist2(p,pf)>=1E-16) { // (*testout) << "ERROR: found two points to project which are different" << endl; // (*testout) << "p=" << p << ", pf=" << pf << endl; different = 1; } } pf = p; fi = i; cnt++; } } /* if (cnt == 2) {(*testout) << "WARNING: found 2 triangles to project" << endl;} if (cnt == 3) {(*testout) << "WARNING: found 3 triangles to project" << endl;} if (cnt > 3) {(*testout) << "WARNING: found more than 3 triangles to project" << endl;} */ if (fi != 0) {lasttrig = fi;} if (fi != 0 && !different) {p3d = pf; return fi;} // (*testout) << "WARNING: Project failed" << endl; return 0; } int STLGeometry :: ProjectNearest(Point<3> & p3d) const { Point<3> p, pf = 0.0; //set new chart const STLChart& chart = GetChart(meshchart); int i; double nearest = 1E50; double dist; int ft = 0; for (i = 1; i <= chart.GetNT(); i++) { p = p3d; dist = GetTriangle(chart.GetTrig(i)).GetNearestPoint(points, p); if (dist < nearest) { pf = p; nearest = dist; ft = chart.GetTrig(i); } } p3d = pf; //if (!ft) {(*testout) << "ERROR: ProjectNearest failed" << endl;} return ft; } //Restrict local h due to curvature for make atlas void STLGeometry :: RestrictLocalHCurv(class Mesh & mesh, double gh) { PushStatusF("Restrict H due to surface curvature"); //bei jedem Dreieck alle Nachbardreiecke vergleichen, und, fallskein Kante dazwischen, //die Meshsize auf ein bestimmtes Mass limitieren int i,j; int ap1,ap2,p3,p4; Point<3> p1p, p2p, p3p, p4p; Vec<3> n, ntn; double rzyl, localh; // double localhfact = 0.5; // double geometryignorelength = 1E-4; double minlocalh = stlparam.atlasminh; Box<3> bb = GetBoundingBox(); // mesh.SetLocalH(bb.PMin() - Vec3d(10, 10, 10),bb.PMax() + Vec3d(10, 10, 10), // mparam.grading); // mesh.SetGlobalH(gh); double mincalch = 1E10; double maxcalch = -1E10 ; double objectsize = bb.Diam(); double geometryignoreedgelength = objectsize * 1e-5; if (stlparam.resthatlasenable) { Array minh; //minimales h pro punkt minh.SetSize(GetNP()); for (i = 1; i <= GetNP(); i++) { minh.Elem(i) = gh; } for (i = 1; i <= GetNT(); i++) { SetThreadPercent((double)i/(double)GetNT()*100.); if (multithread.terminate) {PopStatus(); return;} const STLTriangle& trig = GetTriangle(i); n = GetTriangle(i).Normal(); for (j = 1; j <= 3; j++) { const STLTriangle& nt = GetTriangle(NeighbourTrig(i,j)); trig.GetNeighbourPointsAndOpposite(nt,ap1,ap2,p3); //checken, ob ap1-ap2 eine Kante sind if (IsEdge(ap1,ap2)) continue; p4 = trig.PNum(1) + trig.PNum(2) + trig.PNum(3) - ap1 - ap2; p1p = GetPoint(ap1); p2p = GetPoint(ap2); p3p = GetPoint(p3); p4p = GetPoint(p4); double h1 = GetDistFromInfiniteLine(p1p,p2p, p4p); double h2 = GetDistFromInfiniteLine(p1p,p2p, p3p); double diaglen = Dist (p1p, p2p); if (diaglen < geometryignoreedgelength) continue; rzyl = ComputeCylinderRadius (n, GetTriangle(NeighbourTrig(i,j)).Normal(), h1, h2); if (h1 < 1e-3 * diaglen && h2 < 1e-3 * diaglen) continue; if (h1 < 1e-5 * objectsize && h2 < 1e-5 * objectsize) continue; // rzyl = mindist/(2*sinang); localh = 10.*rzyl / stlparam.resthatlasfac; if (localh < mincalch) {mincalch = localh;} if (localh > maxcalch) {maxcalch = localh;} if (localh < minlocalh) {localh = minlocalh;} if (localh < gh) { minh.Elem(ap1) = min2(minh.Elem(ap1),localh); minh.Elem(ap2) = min2(minh.Elem(ap2),localh); } mesh.RestrictLocalHLine(p1p, p2p, localh); } } } PrintMessage(5, "done\nATLAS H: nmin local h=", mincalch); PrintMessage(5, "ATLAS H: max local h=", maxcalch); PrintMessage(5, "Local h tree has ", mesh.LocalHFunction().GetNBoxes(), " boxes of size ", (int)sizeof(GradingBox)); PopStatus(); } //restrict local h due to near edges and due to outer chart distance void STLGeometry :: RestrictLocalH(class Mesh & mesh, double gh) { //bei jedem Dreieck alle Nachbardreiecke vergleichen, und, fallskein Kante dazwischen, //die Meshsize auf ein bestimmtes Mass limitieren int i,j; int ap1,ap2,p3,p4; Point3d p1p, p2p, p3p, p4p; Vec3d n, ntn; double rzyl, localh; // double localhfact = 0.5; // double geometryignorelength = 1E-4; Box<3> bb = GetBoundingBox(); //mesh.SetLocalH(bb.PMin() - Vec3d(10, 10, 10),bb.PMax() + Vec3d(10, 10, 10), // mparam.grading); //mesh.SetGlobalH(gh); double mincalch = 1E10; double maxcalch = -1E10; double objectsize = bb.Diam(); double geometryignoreedgelength = objectsize * 1e-5; if (stlparam.resthsurfcurvenable) { PushStatusF("Restrict H due to surface curvature"); Array minh; //minimales h pro punkt minh.SetSize(GetNP()); for (i = 1; i <= GetNP(); i++) { minh.Elem(i) = gh; } for (i = 1; i <= GetNT(); i++) { SetThreadPercent((double)i/(double)GetNT()*100.); if (i%20000==19999) {PrintMessage(7, (double)i/(double)GetNT()*100. , "%");} if (multithread.terminate) {PopStatus(); return;} const STLTriangle& trig = GetTriangle(i); n = GetTriangle(i).Normal(); for (j = 1; j <= 3; j++) { const STLTriangle& nt = GetTriangle(NeighbourTrig(i,j)); trig.GetNeighbourPointsAndOpposite(nt,ap1,ap2,p3); //checken, ob ap1-ap2 eine Kante sind if (IsEdge(ap1,ap2)) continue; p4 = trig.PNum(1) + trig.PNum(2) + trig.PNum(3) - ap1 - ap2; p1p = GetPoint(ap1); p2p = GetPoint(ap2); p3p = GetPoint(p3); p4p = GetPoint(p4); double h1 = GetDistFromInfiniteLine(p1p,p2p, p4p); double h2 = GetDistFromInfiniteLine(p1p,p2p, p3p); double diaglen = Dist (p1p, p2p); if (diaglen < geometryignoreedgelength) continue; rzyl = ComputeCylinderRadius (n, GetTriangle (NeighbourTrig(i,j)).Normal(), h1, h2); if (h1 < 1e-3 * diaglen && h2 < 1e-3 * diaglen) continue; if (h1 < 1e-5 * objectsize && h2 < 1e-5 * objectsize) continue; // rzyl = mindist/(2*sinang); localh = rzyl / stlparam.resthsurfcurvfac; if (localh < mincalch) {mincalch = localh;} if (localh > maxcalch) {maxcalch = localh;} if (localh < gh) { minh.Elem(ap1) = min2(minh.Elem(ap1),localh); minh.Elem(ap2) = min2(minh.Elem(ap2),localh); } //if (localh < 0.2) {localh = 0.2;} if(localh < objectsize) mesh.RestrictLocalHLine(p1p, p2p, localh); (*testout) << "restrict h along " << p1p << " - " << p2p << " to " << localh << endl; if (localh < 0.1) { localh = 0.1; } } } PrintMessage(7, "done\nmin local h=", mincalch, "\nmax local h=", maxcalch); PopStatus(); } if (stlparam.resthcloseedgeenable) { PushStatusF("Restrict H due to close edges"); //geht nicht für spiralen!!!!!!!!!!!!!!!!!! double disttohfact = sqr(10.0 / stlparam.resthcloseedgefac); int k,l; double h1, h2, dist; int rc = 0; Point3d p3p1; double mindist = 1E50; PrintMessage(7,"build search tree..."); Box3dTree* lsearchtree = new Box3dTree (GetBoundingBox().PMin() - Vec3d(1,1,1), GetBoundingBox().PMax() + Vec3d(1,1,1)); Array pmins(GetNLines()); Array pmaxs(GetNLines()); double maxhline; for (i = 1; i <= GetNLines(); i++) { maxhline = 0; STLLine* l1 = GetLine(i); Point3d pmin(GetPoint(l1->StartP())), pmax(GetPoint(l1->StartP())), px; for (j = 2; j <= l1->NP(); j++) { px = GetPoint(l1->PNum(j)); maxhline = max2(maxhline,mesh.GetH(px)); pmin.SetToMin (px); pmax.SetToMax (px); } Box3d box(pmin,pmax); box.Increase(maxhline); lsearchtree->Insert (box.PMin(), box.PMax(), i); pmins.Elem(i) = box.PMin(); pmaxs.Elem(i) = box.PMax(); } Array linenums; int k2; for (i = 1; i <= GetNLines(); i++) { SetThreadPercent((double)i/(double)GetNLines()*100.); if (multithread.terminate) {PopStatus(); return;} linenums.SetSize(0); lsearchtree->GetIntersecting(pmins.Get(i),pmaxs.Get(i),linenums); STLLine* l1 = GetLine(i); for (j = 1; j <= l1->NP(); j++) { p3p1 = GetPoint(l1->PNum(j)); h1 = sqr(mesh.GetH(p3p1)); for (k2 = 1; k2 <= linenums.Size(); k2++) { k = linenums.Get(k2); if (k <= i) {continue;} /* //old, without searchtrees for (k = i+1; k <= GetNLines(); k++) { */ STLLine* l2 = GetLine(k); for (l = 1; l <= l2->NP(); l++) { const Point3d& p3p2 = GetPoint(l2->PNum(l)); h2 = sqr(mesh.GetH(p3p2)); dist = Dist2(p3p1,p3p2)*disttohfact; if (dist > 1E-12) { if (dist < h1) { mesh.RestrictLocalH(p3p1,sqrt(dist)); rc++; mindist = min2(mindist,sqrt(dist)); } if (dist < h2) { mesh.RestrictLocalH(p3p2,sqrt(dist)); rc++; mindist = min2(mindist,sqrt(dist)); } } } } } } PrintMessage(5, "done\n Restricted h in ", rc, " points due to near edges!"); PopStatus(); } if (stlparam.resthedgeangleenable) { PushStatusF("Restrict h due to close edges"); int lp1, lp2; Vec3d v1,v2; mincalch = 1E50; maxcalch = -1E50; for (i = 1; i <= GetNP(); i++) { SetThreadPercent((double)i/(double)GetNP()*100.); if (multithread.terminate) {PopStatus(); return;} if (GetNEPP(i) == 2 && !IsLineEndPoint(i)) { if (GetEdge(GetEdgePP(i,1)).PNum(2) == GetEdge(GetEdgePP(i,2)).PNum(1) || GetEdge(GetEdgePP(i,1)).PNum(1) == GetEdge(GetEdgePP(i,2)).PNum(2)) { lp1 = 1; lp2 = 2; } else { lp1 = 2; lp2 = 1; } v1 = Vec3d(GetPoint(GetEdge(GetEdgePP(i,1)).PNum(1)), GetPoint(GetEdge(GetEdgePP(i,1)).PNum(2))); v2 = Vec3d(GetPoint(GetEdge(GetEdgePP(i,2)).PNum(lp1)), GetPoint(GetEdge(GetEdgePP(i,2)).PNum(lp2))); rzyl = ComputeCylinderRadius(v1, v2, v1.Length(), v2.Length()); localh = rzyl / stlparam.resthedgeanglefac; if (localh < mincalch) {mincalch = localh;} if (localh > maxcalch) {maxcalch = localh;} if (localh != 0) mesh.RestrictLocalH(GetPoint(i), localh); } } PrintMessage(7,"edge-angle min local h=", mincalch, "\nedge-angle max local h=", maxcalch); PopStatus(); } if (stlparam.resthchartdistenable) { PushStatusF("Restrict H due to outer chart distance"); // mesh.LocalHFunction().Delete(); //berechne minimale distanz von chart zu einem nicht-outerchart-punkt in jedem randpunkt einer chart Array acttrigs; //outercharttrigs acttrigs.SetSize(GetNT()); for (i = 1; i <= GetNT(); i++) { acttrigs.Elem(i) = 0; } for (i = 1; i <= GetNOCharts(); i++) { SetThreadPercent((double)i/(double)GetNOCharts()*100.); if (multithread.terminate) {PopStatus(); return;} RestrictHChartDistOneChart(i, acttrigs, mesh, gh, 1., 0.); } PopStatus(); } if (stlparam.resthlinelengthenable) { //restrict h due to short lines PushStatusF("Restrict H due to line-length"); double minhl = 1E50; double linefact = 1./stlparam.resthlinelengthfac; double l; for (i = 1; i <= GetNLines(); i++) { SetThreadPercent((double)i/(double)GetNLines()*100.); if (multithread.terminate) {PopStatus(); return;} l = GetLine(i)->GetLength(points); const Point3d& pp1 = GetPoint(GetLine(i)->StartP()); const Point3d& pp2 = GetPoint(GetLine(i)->EndP()); if (l != 0) { minhl = min2(minhl,l*linefact); mesh.RestrictLocalH(pp1, l*linefact); mesh.RestrictLocalH(pp2, l*linefact); } } PopStatus(); PrintMessage(5, "minh due to line length=", minhl); } } void STLGeometry :: RestrictHChartDistOneChart(int chartnum, Array& acttrigs, class Mesh & mesh, double gh, double fact, double minh) { int i = chartnum; int j; double limessafety = stlparam.resthchartdistfac*fact; // original: 2 double localh; double f1,f2; // mincalch = 1E10; //maxcalch = -1E10; Array limes1; Array limes2; Array plimes1; Array plimes2; Array plimes1trigs; //check from wich trig the points come Array plimes2trigs; Array plimes1origin; //either the original pointnumber or zero, if new point int divisions = 10; int k, t, nt, np1, np2; Point3d p3p1, p3p2; STLTriangle tt; limes1.SetSize(0); limes2.SetSize(0); plimes1.SetSize(0); plimes2.SetSize(0); plimes1trigs.SetSize(0); plimes2trigs.SetSize(0); plimes1origin.SetSize(0); STLChart& chart = GetChart(i); chart.ClearOLimit(); chart.ClearILimit(); for (j = 1; j <= chart.GetNChartT(); j++) { t = chart.GetChartTrig(j); tt = GetTriangle(t); for (k = 1; k <= 3; k++) { nt = NeighbourTrig(t,k); if (GetChartNr(nt) != i) { tt.GetNeighbourPoints(GetTriangle(nt),np1,np2); if (!IsEdge(np1,np2) && !GetSpiralPoint(np1) && !GetSpiralPoint(np2)) { p3p1 = GetPoint(np1); p3p2 = GetPoint(np2); if (AddIfNotExists(limes1,np1)) { plimes1.Append(p3p1); plimes1trigs.Append(t); plimes1origin.Append(np1); } if (AddIfNotExists(limes1,np2)) { plimes1.Append(p3p2); plimes1trigs.Append(t); plimes1origin.Append(np2); } chart.AddILimit(twoint(np1,np2)); for (int di = 1; di <= divisions; di++) { f1 = (double)di/(double)(divisions+1.); f2 = (divisions+1.-(double)di)/(double)(divisions+1.); plimes1.Append(Point3d(p3p1.X()*f1+p3p2.X()*f2, p3p1.Y()*f1+p3p2.Y()*f2, p3p1.Z()*f1+p3p2.Z()*f2)); plimes1trigs.Append(t); plimes1origin.Append(0); } } } } } for (j = 1; j <= chart.GetNT(); j++) { acttrigs.Elem(chart.GetTrig(j)) = i; } for (j = 1; j <= chart.GetNOuterT(); j++) { t = chart.GetOuterTrig(j); tt = GetTriangle(t); for (k = 1; k <= 3; k++) { nt = NeighbourTrig(t,k); if (acttrigs.Get(nt) != i) { tt.GetNeighbourPoints(GetTriangle(nt),np1,np2); if (!IsEdge(np1,np2)) { p3p1 = GetPoint(np1); p3p2 = GetPoint(np2); if (AddIfNotExists(limes2,np1)) {plimes2.Append(p3p1); plimes2trigs.Append(t);} if (AddIfNotExists(limes2,np2)) {plimes2.Append(p3p2); plimes2trigs.Append(t);} chart.AddOLimit(twoint(np1,np2)); for (int di = 1; di <= divisions; di++) { f1 = (double)di/(double)(divisions+1.); f2 = (divisions+1.-(double)di)/(double)(divisions+1.); plimes2.Append(Point3d(p3p1.X()*f1+p3p2.X()*f2, p3p1.Y()*f1+p3p2.Y()*f2, p3p1.Z()*f1+p3p2.Z()*f2)); plimes2trigs.Append(t); } } } } } double chartmindist = 1E50; if (plimes2.Size()) { Box3d bbox; bbox.SetPoint (plimes2.Get(1)); for (j = 2; j <= plimes2.Size(); j++) bbox.AddPoint (plimes2.Get(j)); Point3dTree stree(bbox.PMin(), bbox.PMax()); for (j = 1; j <= plimes2.Size(); j++) stree.Insert (plimes2.Get(j), j); Array foundpts; for (j = 1; j <= plimes1.Size(); j++) { double mindist = 1E50; double dist; const Point3d & ap1 = plimes1.Get(j); double boxs = mesh.GetH (plimes1.Get(j)) * limessafety; Point3d pmin = ap1 - Vec3d (boxs, boxs, boxs); Point3d pmax = ap1 + Vec3d (boxs, boxs, boxs); stree.GetIntersecting (pmin, pmax, foundpts); for (int kk = 1; kk <= foundpts.Size(); kk++) { k = foundpts.Get(kk); dist = Dist2(plimes1.Get(j),plimes2.Get(k)); if (dist < mindist) { mindist = dist; } } /* const Point3d & ap1 = plimes1.Get(j); double his = mesh.GetH (plimes1.Get(j)); double xmin = ap1.X() - his * limessafety; double xmax = ap1.X() + his * limessafety; double ymin = ap1.Y() - his * limessafety; double ymax = ap1.Y() + his * limessafety; double zmin = ap1.Z() - his * limessafety; double zmax = ap1.Z() + his * limessafety; for (k = 1; k <= plimes2.Size(); k++) { const Point3d & ap2 = plimes2.Get(k); if (ap2.X() >= xmin && ap2.X() <= xmax && ap2.Y() >= ymin && ap2.Y() <= ymax && ap2.Z() >= zmin && ap2.Z() <= zmax) { dist = Dist2(plimes1.Get(j),plimes2.Get(k)); if (dist < mindist) { mindist = dist; } } } */ mindist = sqrt(mindist); localh = mindist/limessafety; if (localh < minh && localh != 0) {localh = minh;} //minh is generally 0! (except make atlas) if (localh < gh && localh > 0) { mesh.RestrictLocalH(plimes1.Get(j), localh); // if (mindist < mincalch) {mincalch = mindist;} // if (mindist > maxcalch) {maxcalch = mindist;} if (mindist < chartmindist) {chartmindist = mindist;} } } } } //void * STLMeshingDummy (void *) int STLMeshingDummy (STLGeometry* stlgeometry, Mesh*& mesh, int perfstepsstart, int perfstepsend, char* optstring) { if (perfstepsstart > perfstepsend) return 0; multithread.terminate = 0; int success = 1; //int trialcntouter = 0; if (perfstepsstart <= MESHCONST_MESHEDGES) { mesh = new Mesh(); mesh->geomtype = Mesh::GEOM_STL; mesh -> SetGlobalH (mparam.maxh); mesh -> SetLocalH (stlgeometry->GetBoundingBox().PMin() - Vec3d(10, 10, 10), stlgeometry->GetBoundingBox().PMax() + Vec3d(10, 10, 10), mparam.grading); mesh -> LoadLocalMeshSize (mparam.meshsizefilename); success = 0; //mesh->DeleteMesh(); STLMeshing (*stlgeometry, *mesh); stlgeometry->edgesfound = 1; stlgeometry->surfacemeshed = 0; stlgeometry->surfaceoptimized = 0; stlgeometry->volumemeshed = 0; } if (multithread.terminate) return 0; if (perfstepsstart <= MESHCONST_MESHSURFACE && perfstepsend >= MESHCONST_MESHSURFACE) { if (!stlgeometry->edgesfound) { PrintUserError("You have to do 'analyse geometry' first!!!"); return 0; } if (stlgeometry->surfacemeshed || stlgeometry->surfacemeshed) { PrintUserError("Already meshed. Please start again with 'Analyse Geometry'!!!"); return 0; } success = 0; int retval = STLSurfaceMeshing (*stlgeometry, *mesh); if (retval == MESHING3_OK) { PrintMessage(3,"Success !!!!"); stlgeometry->surfacemeshed = 1; stlgeometry->surfaceoptimized = 0; stlgeometry->volumemeshed = 0; success = 1; } else if (retval == MESHING3_OUTERSTEPSEXCEEDED) { PrintError("Give up because of too many trials. Meshing aborted!"); } else if (retval == MESHING3_TERMINATE) { PrintWarning("Meshing Stopped by user!"); } else { PrintError("Surface meshing not successful. Meshing aborted!"); } #ifdef STAT_STREAM (*statout) << mesh->GetNSeg() << " & " << endl << mesh->GetNSE() << " & " << endl << GetTime() << " & "; #endif } if (multithread.terminate) return 0; if (success) { if (perfstepsstart <= MESHCONST_OPTSURFACE && perfstepsend >= MESHCONST_OPTSURFACE) { if (!stlgeometry->edgesfound) { PrintUserError("You have to do 'meshing->analyse geometry' first!!!"); return 0; } if (!stlgeometry->surfacemeshed) { PrintUserError("You have to do 'meshing->mesh surface' first!!!"); return 0; } if (stlgeometry->volumemeshed) { PrintWarning("Surface optimization with meshed volume is dangerous!!!"); } if (!optstring || strlen(optstring) == 0) { mparam.optimize2d = "smcm"; } else { mparam.optimize2d = optstring; } STLSurfaceOptimization (*stlgeometry, *mesh, mparam); if (stlparam.recalc_h_opt) { mesh -> SetLocalH (stlgeometry->GetBoundingBox().PMin() - Vec3d(10, 10, 10), stlgeometry->GetBoundingBox().PMax() + Vec3d(10, 10, 10), mparam.grading); mesh -> LoadLocalMeshSize (mparam.meshsizefilename); mesh -> CalcLocalHFromSurfaceCurvature (stlparam.resthsurfmeshcurvfac); mparam.optimize2d = "cmsmSm"; STLSurfaceOptimization (*stlgeometry, *mesh, mparam); #ifdef STAT_STREAM (*statout) << GetTime() << " & "; #endif extern void Render(); Render(); } stlgeometry->surfaceoptimized = 1; } if (multithread.terminate) return 0; if (perfstepsstart <= MESHCONST_MESHVOLUME && perfstepsend >= MESHCONST_MESHVOLUME) { if (stlgeometry->volumemeshed) { PrintUserError("Volume already meshed!"); return 0; } if (!stlgeometry->edgesfound) { PrintUserError("You have to do 'meshing->analyse geometry' first!!!"); return 0; } if (!stlgeometry->surfacemeshed) { PrintUserError("You have to do 'meshing->mesh surface' first!!!"); return 0; } if (!stlgeometry->surfaceoptimized) { PrintWarning("You should do 'meshing->optimize surface' first!!!"); } PrintMessage(5,"Check Overlapping boundary: "); mesh->FindOpenElements(); mesh->CheckOverlappingBoundary(); PrintMessage(5,""); if (stlparam.recalc_h_opt) { mesh -> SetLocalH (stlgeometry->GetBoundingBox().PMin() - Vec3d(10, 10, 10), stlgeometry->GetBoundingBox().PMax() + Vec3d(10, 10, 10), mparam.grading); mesh -> LoadLocalMeshSize (mparam.meshsizefilename); mesh -> CalcLocalH (); } PrintMessage(5,"Volume meshing"); int retval = MeshVolume (mparam, *mesh); if (retval == MESHING3_OK) { RemoveIllegalElements(*mesh); stlgeometry->volumemeshed = 1; } else if (retval == MESHING3_OUTERSTEPSEXCEEDED) { PrintError("Give up because of too many trials. Meshing aborted!"); return 0; } else if (retval == MESHING3_TERMINATE) { PrintWarning("Meshing Stopped by user!"); } else { PrintError("Volume meshing not successful. Meshing aborted!"); return 0; } #ifdef STAT_STREAM (*statout) << GetTime() << " & " << endl; #endif MeshQuality3d (*mesh); } if (multithread.terminate) return 0; if (perfstepsstart <= MESHCONST_OPTVOLUME && perfstepsend >= MESHCONST_OPTVOLUME) { if (!stlgeometry->edgesfound) { PrintUserError("You have to do 'meshing->analyse geometry' first!!!"); return 0; } if (!stlgeometry->surfacemeshed) { PrintUserError("You have to do 'meshing->mesh surface' first!!!"); return 0; } if (!stlgeometry->volumemeshed) { PrintUserError("You have to do 'meshing->mesh volume' first!!!"); return 0; } if (!optstring || strlen(optstring) == 0) { mparam.optimize3d = "cmdmstm"; } else { mparam.optimize3d = optstring; } OptimizeVolume (mparam, *mesh); #ifdef STAT_STREAM (*statout) << GetTime() << " & " << endl; (*statout) << mesh->GetNE() << " & " << endl << mesh->GetNP() << " " << '\\' << '\\' << " \\" << "hline" << endl; #endif extern void Render(); Render(); } } return 0; } } netgen-4.9.13/libsrc/stlgeom/stlgeomchart.cpp0000644000175000001440000004525111240003503016130 00000000000000//20.11.1999 third part of stlgeom.cc, functions with chart and atlas #include #include #include #include #include #include "stlgeom.hpp" namespace netgen { int chartdebug = 0; void STLGeometry :: MakeAtlas(Mesh & mesh) { double h, h2; h = mparam.maxh; PushStatusF("Make Atlas"); int i,j,k,l; double atlasminh = 5e-3 * Dist (boundingbox.PMin(), boundingbox.PMax()); PrintMessage(5, "atlasminh = ", atlasminh); //speedup for make atlas if (GetNT() > 50000) { mesh.SetGlobalH(0.05*Dist (boundingbox.PMin(), boundingbox.PMax())); } atlas.SetSize(0); ClearSpiralPoints(); BuildSmoothEdges(); double chartangle = stlparam.chartangle; double outerchartangle = stlparam.outerchartangle; chartangle = chartangle/180.*M_PI; outerchartangle = outerchartangle/180.*M_PI; double coschartangle = cos(chartangle); double cosouterchartangle = cos(outerchartangle); double cosouterchartanglehalf = cos(0.5*outerchartangle); double sinchartangle = sin(chartangle); double sinouterchartangle = sin(outerchartangle); Array outermark(GetNT()); //marks all trigs form actual outer region Array outertested(GetNT()); //marks tested trigs for outer region Array pointstochart(GetNP()); //point in chart becomes chartnum Array innerpointstochart(GetNP()); //point in chart becomes chartnum Array chartpoints; //point in chart becomes chartnum Array innerchartpoints; Array dirtycharttrigs; Array chartpointchecked; Array chartdistacttrigs; //outercharttrigs chartdistacttrigs.SetSize(GetNT()); for (i = 1; i <= GetNT(); i++) { chartdistacttrigs.Elem(i) = 0; } STLBoundary chartbound(this); //knows the actual chart boundary //int chartboundarydivisions = 10; markedsegs.SetSize(0); //for testing!!! chartpointchecked.SetSize(GetNP()); //for dirty-chart-trigs outermark.SetSize(GetNT()); outertested.SetSize(GetNT()); pointstochart.SetSize(GetNP()); innerpointstochart.SetSize(GetNP()); chartmark.SetSize(GetNT()); for (i = 1; i <= GetNP(); i++) { innerpointstochart.Elem(i) = 0; pointstochart.Elem(i) = 0; chartpointchecked.Elem(i) = 0; } double eps = 1e-12 * Dist (boundingbox.PMin(), boundingbox.PMax()); int spiralcheckon = stldoctor.spiralcheck; if (!spiralcheckon) {PrintWarning("++++++++++++\nspiral deactivated by user!!!!\n+++++++++++++++"); } for (i = 1; i <= GetNT(); i++) { chartmark.Elem(i) = 0; } for (i = 1; i <= GetNT(); i++) { outermark.Elem(i) = 0; outertested.Elem(i) = 0; } int markedtrigcnt = 0; int found = 1; double atlasarea = Area(); double workedarea = 0; double showinc = 100.*5000./(double)GetNT(); double nextshow = 0; Point<3> startp; int lastunmarked = 1; int prelastunmarked; PrintMessage(5,"one dot per 5000 triangles: "); while(markedtrigcnt < GetNT() && found) { if (multithread.terminate) {PopStatus();return;} if (workedarea / atlasarea*100. >= nextshow) {PrintDot(); nextshow+=showinc;} SetThreadPercent(100.0 * workedarea / atlasarea); /* for (j = 1; j <= GetNT(); j++) { outermark.Elem(j) = 0; } */ STLChart * chart = new STLChart(this); atlas.Append(chart); //find unmarked trig prelastunmarked = lastunmarked; j = lastunmarked; found = 0; while (!found && j <= GetNT()) { if (!GetMarker(j)) {found = 1; lastunmarked = j;} else {j++;} } chartpoints.SetSize(0); innerchartpoints.SetSize(0); chartbound.Clear(); chartbound.SetChart(chart); if (!found) {PrintSysError("Make Atlas, no starttrig found"); return;} //find surrounding trigs int starttrig = j; double tdist; startp = GetPoint(GetTriangle(starttrig).PNum(1)); int accepted; int chartnum = GetNOCharts(); Vec<3> sn = GetTriangle(starttrig).Normal(); chart->SetNormal (startp, sn); SetMarker(starttrig, chartnum); markedtrigcnt++; chart->AddChartTrig(starttrig); chartbound.AddTriangle(GetTriangle(starttrig)); workedarea += GetTriangle(starttrig).Area(points); for (i = 1; i <= 3; i++) { innerpointstochart.Elem(GetTriangle(starttrig).PNum(i)) = chartnum; pointstochart.Elem(GetTriangle(starttrig).PNum(i)) = chartnum; chartpoints.Append(GetTriangle(starttrig).PNum(i)); innerchartpoints.Append(GetTriangle(starttrig).PNum(i)); } Vec<3> n2, n3; int changed = 1; int nt; int ic; int oldstartic = 1; int oldstartic2; int np1, np2; while (changed) { changed = 0; oldstartic2 = oldstartic; oldstartic = chart->GetNT(); // for (ic = oldstartic2; ic <= chart->GetNT(); ic++) for (ic = oldstartic2; ic <= oldstartic; ic++) { i = chart->GetTrig(ic); if (GetMarker(i) == chartnum) { for (j = 1; j <= NONeighbourTrigs(i); j++) { nt = NeighbourTrig(i,j); GetTriangle(i).GetNeighbourPoints(GetTriangle(nt),np1,np2); if (GetMarker(nt) == 0 && !IsEdge(np1,np2)) { n2 = GetTriangle(nt).Normal(); if ( (n2 * sn) >= coschartangle ) { accepted = 1; /* //alter spiralentest, schnell, aber ungenau for (k = 1; k <= 3; k++) { //find overlapping charts: Point3d pt = GetPoint(GetTriangle(nt).PNum(k)); if (innerpointstochart.Get(GetTriangle(nt).PNum(k)) != chartnum) { for (l = 1; l <= chartpoints.Size(); l++) { Vec3d vptpl(GetPoint(chartpoints.Get(l)), pt); double vlen = vptpl.Length(); if (vlen > 0) { vptpl /= vlen; if ( fabs( vptpl * sn) > sinchartangle ) { accepted = 0; break; } } } } } */ int nnp1, nnp2; int nnt; //find overlapping charts exacter: for (k = 1; k <= 3; k++) { nnt = NeighbourTrig(nt,k); if (GetMarker(nnt) != chartnum) { GetTriangle(nt).GetNeighbourPoints(GetTriangle(nnt),nnp1,nnp2); accepted = chartbound.TestSeg(GetPoint(nnp1), GetPoint(nnp2), sn,sinchartangle,1 /*chartboundarydivisions*/ ,points, eps); n3 = GetTriangle(nnt).Normal(); if ( (n3 * sn) >= coschartangle && IsSmoothEdge (nnp1, nnp2) ) accepted = 1; } if (!accepted) {break;} } /* mindist = 1E50; for (int ii = 1; ii <= 3; ii++) { tdist = Dist(GetPoint(GetTriangle(nt).PNum(ii)),startp); if (tdist < mindist) {mindist = tdist;} } if (mindist > maxdist1) {accepted = 0;} */ if (accepted) { SetMarker(nt, chartnum); changed = 1; markedtrigcnt++; workedarea += GetTriangle(nt).Area(points); chart->AddChartTrig(nt); chartbound.AddTriangle(GetTriangle(nt)); for (k = 1; k <= 3; k++) { if (innerpointstochart.Get(GetTriangle(nt).PNum(k)) != chartnum) { innerpointstochart.Elem(GetTriangle(nt).PNum(k)) = chartnum; pointstochart.Elem(GetTriangle(nt).PNum(k)) = chartnum; chartpoints.Append(GetTriangle(nt).PNum(k)); innerchartpoints.Append(GetTriangle(nt).PNum(k)); } } } } } } } } } //find outertrigs // chartbound.Clear(); // warum, ic-bound auf edge macht Probleme js ??? outermark.Elem(starttrig) = chartnum; //chart->AddOuterTrig(starttrig); changed = 1; oldstartic = 1; while (changed) { changed = 0; oldstartic2 = oldstartic; oldstartic = chart->GetNT(); //for (ic = oldstartic2; ic <= chart->GetNT(); ic++) for (ic = oldstartic2; ic <= oldstartic; ic++) { i = chart->GetTrig(ic); if (outermark.Get(i) == chartnum) { for (j = 1; j <= NONeighbourTrigs(i); j++) { nt = NeighbourTrig(i,j); if (outermark.Get(nt) == chartnum) continue; const STLTriangle & ntrig = GetTriangle(nt); GetTriangle(i).GetNeighbourPoints(GetTriangle(nt),np1,np2); if (IsEdge (np1, np2)) continue; /* if (outertested.Get(nt) == chartnum) continue; */ outertested.Elem(nt) = chartnum; n2 = GetTriangle(nt).Normal(); /* double ang; ang = Angle(n2,sn); if (ang < -M_PI*0.5) {ang += 2*M_PI;} (*testout) << "ang < ocharang = " << (fabs(ang) <= outerchartangle); (*testout) << " = " << ( (n2 * sn) >= cosouterchartangle) << endl; // if (fabs(ang) <= outerchartangle) */ //abfragen, ob noch im tolerierten Winkel if ( (n2 * sn) >= cosouterchartangle ) { accepted = 1; int isdirtytrig = 0; Vec<3> gn = GetTriangle(nt).GeomNormal(points); double gnlen = gn.Length(); if (n2 * gn <= cosouterchartanglehalf * gnlen) {isdirtytrig = 1;} //zurueckweisen, falls eine Spiralartige outerchart entsteht int nnp1, nnp2; int nnt; //find overlapping charts exacter: //do not check dirty trigs! if (spiralcheckon && !isdirtytrig) for (k = 1; k <= 3; k++) { nnt = NeighbourTrig(nt,k); if (outermark.Elem(nnt) != chartnum) { GetTriangle(nt).GetNeighbourPoints(GetTriangle(nnt),nnp1,nnp2); accepted = chartbound.TestSeg(GetPoint(nnp1),GetPoint(nnp2), sn,sinouterchartangle, 0 /*chartboundarydivisions*/ ,points, eps); n3 = GetTriangle(nnt).Normal(); if ( (n3 * sn) >= cosouterchartangle && IsSmoothEdge (nnp1, nnp2) ) accepted = 1; } if (!accepted) {break;} } //} // outer chart is only small environment of // inner chart: if (accepted) { accepted = 0; for (k = 1; k <= 3; k++) { if (innerpointstochart.Get(ntrig.PNum(k)) == chartnum) { accepted = 1; break; } } if (!accepted) for (k = 1; k <= 3; k++) { Point<3> pt = GetPoint(ntrig.PNum(k)); h2 = sqr(mesh.GetH(pt)); for (l = 1; l <= innerchartpoints.Size(); l++) { tdist = Dist2(pt, GetPoint (innerchartpoints.Get(l))); if (tdist < 4 * h2) { accepted = 1; break; } } if (accepted) {break;} } } if (accepted) { changed = 1; outermark.Elem(nt) = chartnum; if (GetMarker(nt) != chartnum) { chartbound.AddTriangle(GetTriangle(nt)); chart->AddOuterTrig(nt); for (k = 1; k <= 3; k++) { if (pointstochart.Get(GetTriangle(nt).PNum(k)) != chartnum) { pointstochart.Elem(GetTriangle(nt).PNum(k)) = chartnum; chartpoints.Append(GetTriangle(nt).PNum(k)); } } } } } } } } } //end of while loop for outer chart GetDirtyChartTrigs(chartnum, *chart, outermark, chartpointchecked, dirtycharttrigs); //dirtycharttrigs are local (chart) point numbers!!!!!!!!!!!!!!!! if (dirtycharttrigs.Size() != 0 && (dirtycharttrigs.Size() != chart->GetNChartT() || dirtycharttrigs.Size() != 1)) { if (dirtycharttrigs.Size() == chart->GetNChartT() && dirtycharttrigs.Size() != 1) { //if all trigs would be eliminated -> leave 1 trig! dirtycharttrigs.SetSize(dirtycharttrigs.Size() - 1); } for (k = 1; k <= dirtycharttrigs.Size(); k++) { int tn = chart->GetChartTrig(dirtycharttrigs.Get(k)); outermark.Elem(tn) = 0; //not necessary, for later use SetMarker(tn, 0); markedtrigcnt--; workedarea -= GetTriangle(tn).Area(points); } chart->MoveToOuterChart(dirtycharttrigs); lastunmarked = 1; lastunmarked = prelastunmarked; } //calculate an estimate meshsize, not to produce to large outercharts, with factor 2 larger! RestrictHChartDistOneChart(chartnum, chartdistacttrigs, mesh, h, 0.5, atlasminh); } PrintMessage(5,""); PrintMessage(5,"NO charts=", atlas.Size()); int cnttrias = 0; //int found2; outerchartspertrig.SetSize(GetNT()); for (i = 1; i <= atlas.Size(); i++) { //found2 = 1; for (j = 1; j <= GetChart(i).GetNT(); j++) { int tn = GetChart(i).GetTrig(j); AddOCPT(tn,i); } cnttrias += GetChart(i).GetNT(); } PrintMessage(5, "NO outer chart trias=", cnttrias); //sort outerchartspertrig for (i = 1; i <= GetNT(); i++) { int swap; for (k = 1; k < GetNOCPT(i); k++) { for (j = 1; j < GetNOCPT(i); j++) { swap = GetOCPT(i,j); if (GetOCPT(i,j+1) < swap) { SetOCPT(i,j,GetOCPT(i,j+1)); SetOCPT(i,j+1,swap); } } } // check make atlas if (GetChartNr(i) <= 0 || GetChartNr(i) > GetNOCharts()) { PrintSysError("Make Atlas: chartnr(", i, ")=0!!"); }; } mesh.SetGlobalH(mparam.maxh); mesh.SetMinimalH(mparam.minh); AddConeAndSpiralEdges(); PrintMessage(5,"Make Atlas finished"); PopStatus(); } int STLGeometry::TrigIsInOC(int tn, int ocn) const { if (tn < 1 || tn > GetNT()) { // assert (1); abort (); PrintSysError("STLGeometry::TrigIsInOC illegal tn: ", tn); return 0; } /* int firstval = 0; int i; for (i = 1; i <= GetNOCPT(tn); i++) { if (GetOCPT(tn, i) == ocn) {firstval = 1;} } */ int found = 0; int inc = 1; while (inc <= GetNOCPT(tn)) {inc *= 2;} inc /= 2; int start = inc; while (!found && inc > 0) { if (GetOCPT(tn,start) > ocn) {inc = inc/2; start -= inc;} else if (GetOCPT(tn,start) < ocn) {inc = inc/2; if (start+inc <= GetNOCPT(tn)) {start += inc;}} else {found = 1;} } return GetOCPT(tn, start) == ocn; } int STLGeometry :: GetChartNr(int i) const { if (i > chartmark.Size()) { PrintSysError("GetChartNr(", i, ") not possible!!!"); i = 1; } return chartmark.Get(i); } /* int STLGeometry :: GetMarker(int i) const { return chartmark.Get(i); } */ void STLGeometry :: SetMarker(int nr, int m) { chartmark.Elem(nr) = m; } int STLGeometry :: GetNOCharts() const { return atlas.Size(); } const STLChart& STLGeometry :: GetChart(int nr) const { if (nr > atlas.Size()) { PrintSysError("GetChart(", nr, ") not possible!!!"); nr = 1; } return *(atlas.Get(nr)); } int STLGeometry :: AtlasMade() const { return chartmark.Size() != 0; } //return 1 if not exists int AddIfNotExists(Array& list, int x) { int i; for (i = 1; i <= list.Size(); i++) { if (list.Get(i) == x) {return 0;} } list.Append(x); return 1; } void STLGeometry :: GetInnerChartLimes(Array& limes, int chartnum) { int j, k; int t, nt, np1, np2; limes.SetSize(0); STLChart& chart = GetChart(chartnum); for (j = 1; j <= chart.GetNChartT(); j++) { t = chart.GetChartTrig(j); const STLTriangle& tt = GetTriangle(t); for (k = 1; k <= 3; k++) { nt = NeighbourTrig(t,k); if (GetChartNr(nt) != chartnum) { tt.GetNeighbourPoints(GetTriangle(nt),np1,np2); if (!IsEdge(np1,np2)) { limes.Append(twoint(np1,np2)); /* p3p1 = GetPoint(np1); p3p2 = GetPoint(np2); if (AddIfNotExists(limes,np1)) { plimes1.Append(p3p1); //plimes1trigs.Append(t); //plimes1origin.Append(np1); } if (AddIfNotExists(limes1,np2)) { plimes1.Append(p3p2); //plimes1trigs.Append(t); //plimes1origin.Append(np2); } //chart.AddILimit(twoint(np1,np2)); for (int di = 1; di <= divisions; di++) { double f1 = (double)di/(double)(divisions+1.); double f2 = (divisions+1.-(double)di)/(double)(divisions+1.); plimes1.Append(Point3d(p3p1.X()*f1+p3p2.X()*f2, p3p1.Y()*f1+p3p2.Y()*f2, p3p1.Z()*f1+p3p2.Z()*f2)); //plimes1trigs.Append(t); //plimes1origin.Append(0); } */ } } } } } void STLGeometry :: GetDirtyChartTrigs(int chartnum, STLChart& chart, const Array& outercharttrigs, Array& chartpointchecked, Array& dirtytrigs) { dirtytrigs.SetSize(0); int j,k,n; int np1, np2, nt; int cnt = 0; for (j = 1; j <= chart.GetNChartT(); j++) { int t = chart.GetChartTrig(j); const STLTriangle& tt = GetTriangle(t); for (k = 1; k <= 3; k++) { nt = NeighbourTrig(t,k); if (GetChartNr(nt) != chartnum && outercharttrigs.Get(nt) != chartnum) { tt.GetNeighbourPoints(GetTriangle(nt),np1,np2); if (!IsEdge(np1,np2)) { dirtytrigs.Append(j); //local numbers!!! cnt++; break; //only once per trig!!! } } } } cnt = 0; int ap1, ap2, tn1, tn2, l, problem, pn; Array trigsaroundp; for (j = chart.GetNChartT(); j >= 1; j--) { int t = chart.GetChartTrig(j); const STLTriangle& tt = GetTriangle(t); for (k = 1; k <= 3; k++) { pn = tt.PNum(k); //if (chartpointchecked.Get(pn) == chartnum) //{continue;} int checkpoint = 0; for (n = 1; n <= trigsperpoint.EntrySize(pn); n++) { if (trigsperpoint.Get(pn,n) != t && //ueberfluessig??? GetChartNr(trigsperpoint.Get(pn,n)) != chartnum && outercharttrigs.Get(trigsperpoint.Get(pn,n)) != chartnum) {checkpoint = 1;}; } if (checkpoint) { chartpointchecked.Elem(pn) = chartnum; GetSortedTrianglesAroundPoint(pn,t,trigsaroundp); trigsaroundp.Append(t); //ring problem = 0; //forward: for (l = 2; l <= trigsaroundp.Size()-1; l++) { tn1 = trigsaroundp.Get(l-1); tn2 = trigsaroundp.Get(l); const STLTriangle& t1 = GetTriangle(tn1); const STLTriangle& t2 = GetTriangle(tn2); t1.GetNeighbourPoints(t2, ap1, ap2); if (IsEdge(ap1,ap2)) break; if (GetChartNr(tn2) != chartnum && outercharttrigs.Get(tn2) != chartnum) {problem = 1;} } //backwards: for (l = trigsaroundp.Size()-1; l >= 2; l--) { tn1 = trigsaroundp.Get(l+1); tn2 = trigsaroundp.Get(l); const STLTriangle& t1 = GetTriangle(tn1); const STLTriangle& t2 = GetTriangle(tn2); t1.GetNeighbourPoints(t2, ap1, ap2); if (IsEdge(ap1,ap2)) break; if (GetChartNr(tn2) != chartnum && outercharttrigs.Get(tn2) != chartnum) {problem = 1;} } if (problem && !IsInArray(j,dirtytrigs)) { dirtytrigs.Append(j); cnt++; break; //only once per triangle } } } } } } netgen-4.9.13/libsrc/stlgeom/stltool.cpp0000644000175000001440000006467511240003503015147 00000000000000#include #include #include #include #include #include "stlgeom.hpp" namespace netgen { //add a point into a pointlist, return pointnumber int AddPointIfNotExists(Array& ap, const Point3d& p, double eps) { int i; for (i = 1; i <= ap.Size(); i++) { if (Dist(ap.Get(i),p) <= eps ) {return i;} } return ap.Append(p); } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ double GetDistFromLine(const Point<3> & lp1, const Point<3> & lp2, Point<3> & p) { Vec3d vn = lp2 - lp1; Vec3d v1 = p - lp1; Vec3d v2 = lp2 - p; Point3d pold = p; if (v2 * vn <= 0) {p = lp2; return (pold - p).Length();} if (v1 * vn <= 0) {p = lp1; return (pold - p).Length();} double vnl = vn.Length(); if (vnl == 0) {return Dist(lp1,p);} vn /= vnl; p = lp1 + (v1 * vn) * vn; return (pold - p).Length(); }; double GetDistFromInfiniteLine(const Point<3>& lp1, const Point<3>& lp2, const Point<3>& p) { Vec3d vn(lp1, lp2); Vec3d v1(lp1, p); double vnl = vn.Length(); if (vnl == 0) { return Dist (lp1, p); } else { return Cross (vn, v1).Length() / vnl; } }; //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //Binary IO-Manipulation void FIOReadInt(istream& ios, int& i) { const int ilen = sizeof(int); char buf[ilen]; int j; for (j = 0; j < ilen; j++) { ios.get(buf[j]); } memcpy(&i, &buf, ilen); } void FIOWriteInt(ostream& ios, const int& i) { const int ilen = sizeof(int); char buf[ilen]; memcpy(&buf, &i, ilen); int j; for (j = 0; j < ilen; j++) { ios << buf[j]; } } void FIOReadDouble(istream& ios, double& i) { const int ilen = sizeof(double); char buf[ilen]; int j; for (j = 0; j < ilen; j++) { ios.get(buf[j]); } memcpy(&i, &buf, ilen); } void FIOWriteDouble(ostream& ios, const double& i) { const int ilen = sizeof(double); char buf[ilen]; memcpy(&buf, &i, ilen); int j; for (j = 0; j < ilen; j++) { ios << buf[j]; } } void FIOReadFloat(istream& ios, float& i) { const int ilen = sizeof(float); char buf[ilen]; int j; for (j = 0; j < ilen; j++) { ios.get(buf[j]); } memcpy(&i, &buf, ilen); } void FIOWriteFloat(ostream& ios, const float& i) { const int ilen = sizeof(float); char buf[ilen]; memcpy(&buf, &i, ilen); int j; for (j = 0; j < ilen; j++) { ios << buf[j]; } } void FIOReadString(istream& ios, char* str, int len) { int j; for (j = 0; j < len; j++) { ios.get(str[j]); } } //read string and add terminating 0 void FIOReadStringE(istream& ios, char* str, int len) { int j; for (j = 0; j < len; j++) { ios.get(str[j]); } str[len] = 0; } void FIOWriteString(ostream& ios, char* str, int len) { int j; for (j = 0; j < len; j++) { ios << str[j]; } } /* void FIOReadInt(istream& ios, int& i) { const int ilen = sizeof(int); char buf[ilen]; int j; for (j = 0; j < ilen; j++) { ios.get(buf[ilen-j-1]); } memcpy(&i, &buf, ilen); } void FIOWriteInt(ostream& ios, const int& i) { const int ilen = sizeof(int); char buf[ilen]; memcpy(&buf, &i, ilen); int j; for (j = 0; j < ilen; j++) { ios << buf[ilen-j-1]; } } void FIOReadDouble(istream& ios, double& i) { const int ilen = sizeof(double); char buf[ilen]; int j; for (j = 0; j < ilen; j++) { ios.get(buf[ilen-j-1]); } memcpy(&i, &buf, ilen); } void FIOWriteDouble(ostream& ios, const double& i) { const int ilen = sizeof(double); char buf[ilen]; memcpy(&buf, &i, ilen); int j; for (j = 0; j < ilen; j++) { ios << buf[ilen-j-1]; } } void FIOReadFloat(istream& ios, float& i) { const int ilen = sizeof(float); char buf[ilen]; int j; for (j = 0; j < ilen; j++) { ios.get(buf[ilen-j-1]); } memcpy(&i, &buf, ilen); } void FIOWriteFloat(ostream& ios, const float& i) { const int ilen = sizeof(float); char buf[ilen]; memcpy(&buf, &i, ilen); int j; for (j = 0; j < ilen; j++) { ios << buf[ilen-j-1]; } } void FIOReadString(istream& ios, char* str, int len) { int j; for (j = 0; j < len; j++) { ios.get(str[j]); } } //read string and add terminating 0 void FIOReadStringE(istream& ios, char* str, int len) { int j; for (j = 0; j < len; j++) { ios.get(str[j]); } str[len] = 0; } void FIOWriteString(ostream& ios, char* str, int len) { int j; for (j = 0; j < len; j++) { ios << str[j]; } } */ //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ STLReadTriangle :: STLReadTriangle (const Point<3> * apts, const Vec<3> & anormal) { pts[0] = apts[0]; pts[1] = apts[1]; pts[2] = apts[2]; normal = anormal; } STLTriangle :: STLTriangle(const int * apts) { pts[0] = apts[0]; pts[1] = apts[1]; pts[2] = apts[2]; facenum = 0; } int STLTriangle :: IsNeighbourFrom(const STLTriangle& t) const { //triangles must have same orientation!!! int i, j; for(i = 0; i <= 2; i++) { for(j = 0; j <= 2; j++) { if (t.pts[(i+1)%3] == pts[j] && t.pts[i] == pts[(j+1)%3]) {return 1;} } } return 0; } int STLTriangle :: IsWrongNeighbourFrom(const STLTriangle& t) const { //triangles have not same orientation!!! int i, j; for(i = 0; i <= 2; i++) { for(j = 0; j <= 2; j++) { if (t.pts[(i+1)%3] == pts[(j+1)%3] && t.pts[i] == pts[j]) {return 1;} } } return 0; } void STLTriangle :: GetNeighbourPoints(const STLTriangle& t, int& p1, int& p2) const { int i, j; for(i = 1; i <= 3; i++) { for(j = 1; j <= 3; j++) { if (t.PNumMod(i+1) == PNumMod(j) && t.PNumMod(i) == PNumMod(j+1)) {p1 = PNumMod(j); p2 = PNumMod(j+1); return;} } } PrintSysError("Get neighbourpoints failed!"); } int STLTriangle :: GetNeighbourPointsAndOpposite(const STLTriangle& t, int& p1, int& p2, int& po) const { int i, j; for(i = 1; i <= 3; i++) { for(j = 1; j <= 3; j++) { if (t.PNumMod(i+1) == PNumMod(j) && t.PNumMod(i) == PNumMod(j+1)) {p1 = PNumMod(j); p2 = PNumMod(j+1); po = PNumMod(j+2); return 1;} } } return 0; } Vec<3> STLTriangle :: GeomNormal(const Array >& ap) const { const Point<3> & p1 = ap.Get(PNum(1)); const Point<3> & p2 = ap.Get(PNum(2)); const Point<3> & p3 = ap.Get(PNum(3)); return Cross(p2-p1, p3-p1); } void STLTriangle :: SetNormal (const Vec<3> & n) { double len = n.Length(); if (len > 0) { normal = n; normal.Normalize(); } else { normal = Vec<3> (1, 0, 0); } } void STLTriangle :: ChangeOrientation() { normal *= -1; Swap(pts[0],pts[1]); } double STLTriangle :: Area(const Array >& ap) const { return 0.5 * Cross(ap.Get(PNum(2))-ap.Get(PNum(1)), ap.Get(PNum(3))-ap.Get(PNum(1))).Length(); } double STLTriangle :: MinHeight(const Array >& ap) const { double ml = MaxLength(ap); if (ml != 0) {return 2.*Area(ap)/ml;} PrintWarning("max Side Length of a triangle = 0!!!"); return 0; } double STLTriangle :: MaxLength(const Array >& ap) const { return max3(Dist(ap.Get(PNum(1)),ap.Get(PNum(2))), Dist(ap.Get(PNum(2)),ap.Get(PNum(3))), Dist(ap.Get(PNum(3)),ap.Get(PNum(1)))); } void STLTriangle :: ProjectInPlain(const Array >& ap, const Vec<3> & n, Point<3> & pp) const { const Point<3> & p1 = ap.Get(PNum(1)); const Point<3> & p2 = ap.Get(PNum(2)); const Point<3> & p3 = ap.Get(PNum(3)); Vec<3> v1 = p2 - p1; Vec<3> v2 = p3 - p1; Vec<3> nt = Cross(v1, v2); double c = - (p1(0)*nt(0) + p1(1)*nt(1) + p1(2)*nt(2)); double prod = n * nt; if (fabs(prod) == 0) { pp = Point<3>(1.E20,1.E20,1.E20); return; } double nfact = -(pp(0)*nt(0) + pp(1)*nt(1) + pp(2)*nt(2) + c) / (prod); pp = pp + (nfact) * n; } int STLTriangle :: ProjectInPlain (const Array >& ap, const Vec<3> & nproj, Point<3> & pp, Vec<3> & lam) const { const Point<3> & p1 = ap.Get(PNum(1)); const Point<3> & p2 = ap.Get(PNum(2)); const Point<3> & p3 = ap.Get(PNum(3)); Vec<3> v1 = p2-p1; Vec<3> v2 = p3-p1; Mat<3> mat; for (int i = 0; i < 3; i++) { mat(i,0) = v1(i); mat(i,1) = v2(i); mat(i,2) = nproj(i); } int err = 0; mat.Solve (pp-p1, lam); // int err = SolveLinearSystem (v1, v2, nproj, pp-p1, lam); if (!err) { // pp = p1 + lam(0) * v1 + lam(1) * v2; pp(0) = p1(0) + lam(0) * v1(0) + lam(1) * v2(0); pp(1) = p1(1) + lam(0) * v1(1) + lam(1) * v2(1); pp(2) = p1(2) + lam(0) * v1(2) + lam(1) * v2(2); } return err; } void STLTriangle :: ProjectInPlain(const Array >& ap, Point<3> & pp) const { const Point<3> & p1 = ap.Get(PNum(1)); const Point<3> & p2 = ap.Get(PNum(2)); const Point<3> & p3 = ap.Get(PNum(3)); Vec<3> v1 = p2 - p1; Vec<3> v2 = p3 - p1; Vec<3> nt = Cross(v1, v2); double c = - (p1(0)*nt(0) + p1(1)*nt(1) + p1(2)*nt(2)); double prod = nt * nt; double nfact = -(pp(0)*nt(0) + pp(1)*nt(1) + pp(2)*nt(2) + c) / (prod); pp = pp + (nfact) * nt; } int STLTriangle :: PointInside(const Array > & ap, const Point<3> & pp) const { const Point<3> & p1 = ap.Get(PNum(1)); const Point<3> & p2 = ap.Get(PNum(2)); const Point<3> & p3 = ap.Get(PNum(3)); Vec<3> v1 = p2 - p1; Vec<3> v2 = p3 - p1; Vec<3> v = pp - p1; double det, l1, l2; Vec<3> ex, ey, ez; ez = GeomNormal(ap); ez /= ez.Length(); ex = v1; ex /= ex.Length(); ey = Cross (ez, ex); Vec<2> v1p(v1*ex, v1*ey); Vec<2> v2p(v2*ex, v2*ey); Vec<2> vp(v*ex, v*ey); det = v2p(1) * v1p(0) - v2p(0) * v1p(1); if (fabs(det) == 0) {return 0;} l2 = (vp(1) * v1p(0) - vp(0) * v1p(1)) / det; if (v1p(0) != 0.) { l1 = (vp(0) - l2 * v2p(0)) / v1p(0); } else if (v1p(1) != 0.) { l1 = (vp(1) - l2 * v2p(1)) / v1p(1); } else {return 0;} if (l1 >= -1E-10 && l2 >= -1E-10 && l1 + l2 <= 1.+1E-10) {return 1;} return 0; } double STLTriangle :: GetNearestPoint(const Array >& ap, Point<3> & p3d) const { Point<3> p = p3d; ProjectInPlain(ap, p); double dist = (p - p3d).Length(); if (PointInside(ap, p)) {p3d = p; return dist;} else { Point<3> pf = 0.0; double nearest = 1E50; //int fi = 0; for (int j = 1; j <= 3; j++) { p = p3d; dist = GetDistFromLine(ap.Get(PNum(j)), ap.Get(PNumMod(j+1)), p); if (dist < nearest) { nearest = dist; pf = p; } } p3d = pf; return nearest; } } int STLTriangle :: HasEdge(int p1, int p2) const { int i; for (i = 1; i <= 3; i++) { if (p1 == PNum(i) && p2 == PNumMod(i+1)) {return 1;} } return 0; } ostream& operator<<(ostream& os, const STLTriangle& t) { os << "["; os << t[0] << ","; os << t[1] << ","; os << t[2] << "]"; return os; }; STLTopEdge :: STLTopEdge () { pts[0] = pts[1] = 0; trigs[0] = trigs[1] = 0; cosangle = 1; status = ED_UNDEFINED; } STLTopEdge :: STLTopEdge (int p1, int p2, int trig1, int trig2) { pts[0] = p1; pts[1] = p2; trigs[0] = trig1; trigs[1] = trig2; cosangle = 1; status = ED_UNDEFINED; } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++ STL CHART +++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ STLChart :: STLChart(STLGeometry * ageometry) { charttrigs = new Array (0,0); outertrigs = new Array (0,0); ilimit = new Array (0,0); olimit = new Array (0,0); geometry = ageometry; if ( (stlparam.usesearchtree == 1)) searchtree = new Box3dTree (geometry->GetBoundingBox().PMin() - Vec3d(1,1,1), geometry->GetBoundingBox().PMax() + Vec3d(1,1,1)); else searchtree = NULL; } void STLChart :: AddChartTrig(int i) { charttrigs->Append(i); const STLTriangle & trig = geometry->GetTriangle(i); const Point3d & p1 = geometry->GetPoint (trig.PNum(1)); const Point3d & p2 = geometry->GetPoint (trig.PNum(2)); const Point3d & p3 = geometry->GetPoint (trig.PNum(3)); Point3d pmin(p1), pmax(p1); pmin.SetToMin (p2); pmin.SetToMin (p3); pmax.SetToMax (p2); pmax.SetToMax (p3); if (!geomsearchtreeon && (stlparam.usesearchtree == 1)) {searchtree->Insert (pmin, pmax, i);} } void STLChart :: AddOuterTrig(int i) { outertrigs->Append(i); const STLTriangle & trig = geometry->GetTriangle(i); const Point3d & p1 = geometry->GetPoint (trig.PNum(1)); const Point3d & p2 = geometry->GetPoint (trig.PNum(2)); const Point3d & p3 = geometry->GetPoint (trig.PNum(3)); Point3d pmin(p1), pmax(p1); pmin.SetToMin (p2); pmin.SetToMin (p3); pmax.SetToMax (p2); pmax.SetToMax (p3); if (!geomsearchtreeon && (stlparam.usesearchtree==1)) {searchtree->Insert (pmin, pmax, i);} } int STLChart :: IsInWholeChart(int nr) const { int i; for (i = 1; i <= charttrigs->Size(); i++) { if (charttrigs->Get(i) == nr) {return 1;} } for (i = 1; i <= outertrigs->Size(); i++) { if (outertrigs->Get(i) == nr) {return 1;} } return 0; } void STLChart :: GetTrianglesInBox (const Point3d & pmin, const Point3d & pmax, Array & trias) const { if (geomsearchtreeon) {PrintMessage(5,"geomsearchtreeon is set!!!");} if (searchtree) searchtree -> GetIntersecting (pmin, pmax, trias); else { int i; Box3d box1(pmin, pmax); box1.Increase (1e-4); Box3d box2; trias.SetSize(0); int nt = GetNT(); for (i = 1; i <= nt; i++) { int trignum = GetTrig(i); const STLTriangle & trig = geometry->GetTriangle(trignum); box2.SetPoint (geometry->GetPoint (trig.PNum(1))); box2.AddPoint (geometry->GetPoint (trig.PNum(2))); box2.AddPoint (geometry->GetPoint (trig.PNum(3))); if (box1.Intersect (box2)) { trias.Append (trignum); } } } } //trigs may contain the same triangle double void STLChart :: MoveToOuterChart(const Array& trigs) { if (!trigs.Size()) {return;} int i; for (i = 1; i <= trigs.Size(); i++) { if (charttrigs->Get(trigs.Get(i)) != -1) {AddOuterTrig(charttrigs->Get(trigs.Get(i)));} charttrigs->Elem(trigs.Get(i)) = -1; } DelChartTrigs(trigs); } //trigs may contain the same triangle double void STLChart :: DelChartTrigs(const Array& trigs) { if (!trigs.Size()) {return;} int i; for (i = 1; i <= trigs.Size(); i++) { charttrigs->Elem(trigs.Get(i)) = -1; } int cnt = 0; for (i = 1; i <= charttrigs->Size(); i++) { if (charttrigs->Elem(i) == -1) { cnt++; } if (cnt != 0 && i < charttrigs->Size()) { charttrigs->Elem(i-cnt+1) = charttrigs->Get(i+1); } } i = charttrigs->Size() - trigs.Size(); charttrigs->SetSize(i); if (!geomsearchtreeon && stlparam.usesearchtree == 1) { PrintMessage(7, "Warning: unsecure routine due to first use of searchtrees!!!"); //bould new searchtree!!! searchtree = new Box3dTree (geometry->GetBoundingBox().PMin() - Vec3d(1,1,1), geometry->GetBoundingBox().PMax() + Vec3d(1,1,1)); for (i = 1; i <= charttrigs->Size(); i++) { const STLTriangle & trig = geometry->GetTriangle(i); const Point3d & p1 = geometry->GetPoint (trig.PNum(1)); const Point3d & p2 = geometry->GetPoint (trig.PNum(2)); const Point3d & p3 = geometry->GetPoint (trig.PNum(3)); Point3d pmin(p1), pmax(p1); pmin.SetToMin (p2); pmin.SetToMin (p3); pmax.SetToMax (p2); pmax.SetToMax (p3); searchtree->Insert (pmin, pmax, i); } } } void STLChart :: SetNormal (const Point<3> & apref, const Vec<3> & anormal) { pref = apref; normal = anormal; double len = normal.Length(); if (len) normal /= len; else normal = Vec<3> (1, 0, 0); t1 = normal.GetNormal (); t2 = Cross (normal, t1); } Point<2> STLChart :: Project2d (const Point<3> & p3d) const { Vec<3> v = p3d-pref; return Point<2> (t1 * v, t2 * v); } /* Point3d p1, p2, center; double rad; int i1, i2; public: */ STLBoundarySeg :: STLBoundarySeg (int ai1, int ai2, const Array > & points, const STLChart * chart) { i1 = ai1; i2 = ai2; p1 = points.Get(i1); p2 = points.Get(i2); center = ::netgen::Center (p1, p2); rad = Dist (p1, center); p2d1 = chart->Project2d (p1); p2d2 = chart->Project2d (p2); boundingbox.Set (p2d1); boundingbox.Add (p2d2); } void STLBoundarySeg :: Swap () { ::netgen::Swap (i1, i2); ::netgen::Swap (p1, p2); } STLBoundary :: STLBoundary (STLGeometry * ageometry) : boundary(), geometry(ageometry) { ; } void STLBoundary :: AddOrDelSegment(const STLBoundarySeg & seg) { int i; int found = 0; for (i = 1; i <= boundary.Size(); i++) { if (found) {boundary.Elem(i-1) = boundary.Get(i);} if (boundary.Get(i) == seg) {found = 1;} } if (!found) { boundary.Append(seg); } else { boundary.SetSize(boundary.Size()-1); } } void STLBoundary ::AddTriangle(const STLTriangle & t) { int i; int found1 = 0; int found2 = 0; int found3 = 0; //int offset = 0; STLBoundarySeg seg1(t[0],t[1], geometry->GetPoints(), chart); STLBoundarySeg seg2(t[1],t[2], geometry->GetPoints(), chart); STLBoundarySeg seg3(t[2],t[0], geometry->GetPoints(), chart); seg1.SetSmoothEdge (geometry->IsSmoothEdge (seg1.I1(), seg1.I2())); seg2.SetSmoothEdge (geometry->IsSmoothEdge (seg2.I1(), seg2.I2())); seg3.SetSmoothEdge (geometry->IsSmoothEdge (seg3.I1(), seg3.I2())); /* for (i = 1; i <= boundary.Size(); i++) { if (offset) {boundary.Elem(i-offset) = boundary.Get(i);} if (boundary.Get(i) == seg1) {found1 = 1; offset++;} if (boundary.Get(i) == seg2) {found2 = 1; offset++;} if (boundary.Get(i) == seg3) {found3 = 1; offset++;} } if (offset) { boundary.SetSize(boundary.Size()-offset); } */ for (i = boundary.Size(); i >= 1; i--) { if (boundary.Get(i) == seg1) { boundary.DeleteElement (i); found1 = 1; } else if (boundary.Get(i) == seg2) { boundary.DeleteElement (i); found2 = 1; } else if (boundary.Get(i) == seg3) { boundary.DeleteElement (i); found3 = 1; } } if (!found1) {seg1.Swap(); boundary.Append(seg1);} if (!found2) {seg2.Swap(); boundary.Append(seg2);} if (!found3) {seg3.Swap(); boundary.Append(seg3);} } int STLBoundary :: TestSeg(const Point<3>& p1, const Point<3> & p2, const Vec<3> & sn, double sinchartangle, int divisions, Array >& points, double eps) { if (usechartnormal) return TestSegChartNV (p1, p2, sn); // for statistics { int i; static Array cntclass; static int cnt = 0; static int cnti = 0, cnto = 0; static long int cntsegs = 0; if (cntclass.Size() == 0) { cntclass.SetSize (20); for (i = 1; i <= cntclass.Size(); i++) cntclass.Elem(i) = 0; } cntsegs += NOSegments(); int cla = int (log (double(NOSegments()+1)) / log(2.0)); if (cla < 1) cla = 1; if (cla > cntclass.Size()) cla = cntclass.Size(); cntclass.Elem(cla)++; cnt++; if (divisions) cnti++; else cnto++; if (cnt > 100000) { cnt = 0; /* (*testout) << "TestSeg-calls for classes:" << endl; (*testout) << cnti << " inner calls, " << cnto << " outercalls" << endl; (*testout) << "total testes segments: " << cntsegs << endl; for (i = 1; i <= cntclass.Size(); i++) { (*testout) << int (exp (i * log(2.0))) << " bnd segs: " << cntclass.Get(i) << endl; } */ } } int i,j,k; Point<3> seg1p/*, seg2p*/; Point<3> sp1,sp2; double lambda1, lambda2, vlen2; Vec<3> vptpl; double sinchartangle2 = sqr(sinchartangle); double scal; int possible; //double maxval = -1; //double maxvalnew = -1; double scalp1 = p1(0) * sn(0) + p1(1) * sn(1) + p1(2) * sn(2); double scalp2 = p2(0) * sn(0) + p2(1) * sn(1) + p2(2) * sn(2); double minl = min2(scalp1, scalp2); double maxl = max2(scalp1, scalp2); Point<3> c = Center (p1, p2); double dist1 = Dist (c, p1); int nseg = NOSegments(); for (j = 1; j <= nseg; j++) { const STLBoundarySeg & seg = GetSegment(j); if (seg.IsSmoothEdge()) continue; sp1 = seg.P1(); sp2 = seg.P2(); // Test, ob Spiral Konfikt moeglich possible = 1; double scalsp1 = sp1(0) * sn(0) + sp1(1) * sn(1) + sp1(2) * sn(2); double scalsp2 = sp2(0) * sn(0) + sp2(1) * sn(1) + sp2(2) * sn(2); double minsl = min2(scalsp1, scalsp2); double maxsl = max2(scalsp1, scalsp2); double maxdiff = max2 (maxsl - minl, maxl - minsl); /* Point3d sc = Center (sp1, sp2); double mindist = Dist(c, sc) - dist1 - GetSegment(j).Radius(); if (maxdiff < sinchartangle * mindist) { possible = 0; } */ double hscal = maxdiff + sinchartangle * (dist1 + seg.Radius()); if (hscal * hscal < sinchartangle * Dist2(c, seg.center )) possible = 0; /* if (possible) { double mindist2ex = MinDistLL2 (p1, p2, sp1, sp2); if (maxdiff * maxdiff < sinchartangle2 * mindist2ex) possible = 0; } */ if (possible) { LinearPolynomial2V lp (scalp1 - scalsp1, scalp2 - scalp1, -(scalsp2 - scalsp1)); QuadraticPolynomial2V slp; slp.Square (lp); Vec3d v (p1, sp1); Vec3d vl (p1, p2); Vec3d vsl (sp1, sp2); QuadraticPolynomial2V qp (v.Length2(), -2 * (v * vl), 2 * (v * vsl), vl.Length2(), -2 * (vl * vsl), vsl.Length2()); slp.Add (-sinchartangle2, qp); double hv = slp.MaxUnitSquare(); if (hv > eps) return 0; /* if (hv > maxvalnew) maxvalnew = hv; */ } if (possible && 0) for (i = 0; i <= divisions; i++) { lambda1 = (double)i/(double)divisions; seg1p = Point3d(p1(0)*lambda1+p2(0)*(1.-lambda1), p1(1)*lambda1+p2(1)*(1.-lambda1), p1(2)*lambda1+p2(2)*(1.-lambda1)); for (k = 0; k <= divisions; k++) { lambda2 = (double)k/(double)divisions; vptpl = Vec3d(sp1(0)*lambda2+sp2(0)*(1.-lambda2)-seg1p(0), sp1(1)*lambda2+sp2(1)*(1.-lambda2)-seg1p(1), sp1(2)*lambda2+sp2(2)*(1.-lambda2)-seg1p(2)); vlen2 = vptpl.Length2(); // if (vlen2 > 0) { scal = vptpl * sn; double hv = scal*scal - sinchartangle2*vlen2; /* if (hv > maxval) maxval = hv; */ if (hv > eps) return 0; } } } } return 1; // return (maxvalnew < eps); } // checks, whether 2d projection intersects int STLBoundary :: TestSegChartNV(const Point3d & p1, const Point3d& p2, const Vec3d& sn) { int j; int nseg = NOSegments(); Point<2> p2d1 = chart->Project2d (p1); Point<2> p2d2 = chart->Project2d (p2); Box<2> box2d; box2d.Set (p2d1); box2d.Add (p2d2); /* Point2d pmin(p2d1); pmin.SetToMin (p2d2); Point2d pmax(p2d1); pmax.SetToMax (p2d2); */ Line2d l1 (p2d1, p2d2); double lam1, lam2; double eps = 1e-3; for (j = 1; j <= nseg; j++) { const STLBoundarySeg & seg = GetSegment(j); if (!box2d.Intersect (seg.BoundingBox())) continue; /* if (seg.P2DMin()(0) > pmax(0)) continue; if (seg.P2DMin()(1) > pmax(1)) continue; if (seg.P2DMax()(0) < pmin(0)) continue; if (seg.P2DMax()(1) < pmin(1)) continue; */ if (seg.IsSmoothEdge()) continue; const Point<2> & sp1 = seg.P2D1(); const Point<2> & sp2 = seg.P2D2(); Line2d l2 (sp1, sp2); int err = CrossPointBarycentric (l1, l2, lam1, lam2); /* if (chartdebug) { (*testout) << "lam1 = " << lam1 << ", lam2 = " << lam2 << endl; (*testout) << "p2d = " << p2d1 << ", " << p2d2 << endl; (*testout) << "sp2d = " << sp1 << ", " << sp2 << endl; (*testout) << "i1,2 = " << seg.I1() << ", " << seg.I2() << endl; } */ if (!err && lam1 > eps && lam1 < 1-eps && lam2 > eps && lam2 < 1-eps) return 0; } return 1; } STLDoctorParams :: STLDoctorParams() { drawmeshededges = 1; geom_tol_fact = 1E-6; longlinefact = 0; showexcluded = 1; selectmode = 0; edgeselectmode = 0; useexternaledges = 0; showfaces = 0; showtouchedtrigchart = 1; showedgecornerpoints = 1; conecheck = 1; spiralcheck = 1; selecttrig = 0; nodeofseltrig = 1; selectwithmouse = 1; showmarkedtrigs = 1; dirtytrigfact = 0.001; smoothangle = 90; smoothnormalsweight = 0.2; vicinity = 0; showvicinity = 0; } STLDoctorParams stldoctor; void STLDoctorParams :: Print (ostream & ost) const { ost << "STL doctor parameters:" << endl << "selecttrig = " << selecttrig << endl << "selectlocalpoint = " << nodeofseltrig << endl << "selectwithmouse = " << selectwithmouse << endl << "showmarkedtrigs = " << showmarkedtrigs << endl << "dirtytrigfact = " << dirtytrigfact << endl << "smoothangle = " << smoothangle << endl; } STLParameters :: STLParameters() { yangle = 30; contyangle = 20; edgecornerangle = 60; chartangle = 15; outerchartangle = 70; usesearchtree = 0; atlasminh = 1E-4; resthsurfcurvfac = 2; resthsurfcurvenable = 0; resthatlasfac = 2; resthatlasenable = 1; resthchartdistfac = 1.2; resthchartdistenable = 1; resthlinelengthfac = 0.5; resthlinelengthenable = 1; resthcloseedgefac = 1; resthcloseedgeenable = 1; resthedgeanglefac = 1; resthedgeangleenable = 0; resthsurfmeshcurvfac = 1; resthsurfmeshcurvenable = 0; recalc_h_opt = 1; } void STLParameters :: Print (ostream & ost) const { ost << "STL parameters:" << endl << "yellow angle = " << yangle << endl << "continued yellow angle = " << contyangle << endl << "edgecornerangle = " << edgecornerangle << endl << "chartangle = " << chartangle << endl << "outerchartangle = " << outerchartangle << endl << "restrict h due to ..., enable and safety factor: " << endl << "surface curvature: " << resthsurfcurvenable << ", fac = " << resthsurfcurvfac << endl << "atlas surface curvature: " << resthatlasenable << ", fac = " << resthatlasfac << endl << "chart distance: " << resthchartdistenable << ", fac = " << resthchartdistfac << endl << "line length: " << resthlinelengthenable << ", fac = " << resthlinelengthfac << endl << "close edges: " << resthcloseedgeenable << ", fac = " << resthcloseedgefac << endl << "edge angle: " << resthedgeangleenable << ", fac = " << resthedgeanglefac << endl; } STLParameters stlparam; }