
# This is the customized version of autohex that runs inside of med
#
# Copyright (c) 1993, 1994 Pacific Marketing and Consulting
# Author:  Wayne A. Christopher, wayne@pmac.com
#          Pacific Marketing and Consulting, Berkeley, California

set autohex_root $med_root
set auto_debug [info exists env(AUTO_DEBUG)]

#set use_grid_grading 0
set advanced_mesher_ok 1
set allow_multi_thick_quads 0
set autohex_dir $auto_tool_dir
set current_mtype none
set current_object ""
set current_shape ""
set default_job_directory ""
set domain ""
set dont_remove_faces_between_solids 1
set edit_geometry_okay 1
set edit_nameactive_okay 1
set edit_no_units 1
set form_entry_justify_right 1
set grid_license_found(global) 1
set grid_license_found(hexa) 1
set grid_license_found(mesher) 1
set grid_license_found(tetra) 1
set grid_quality_warning 1
set grid_type ""
set job_directory ""
set job_name ""
set job_version ""
set library_path ""
set no_full_msgs_buttons 1
set options(select_mode) all
set part_container ""
set projlib ""
set shading_type wire
set undo_tag 0
set use_display_edges 1
set use_grid_grading 1
set use_indomain_button 1
set want_bar_elements 1
set default_fluid_family FLUID
set default_side_family WALL

array set try_suff {
    sgi { sgi sgi5 sgi6 }
    hp  { hp hp9 hp10 }
    ibm { ibm ibm41 ibm42 }
    sol { sol solaris sol5 }
    alpha { alpha alpha40 }
    win - win40 { win40 }
    decwin - decwin40 { decwin40 }
    linux { linux }
}

foreach prog {
    global tetra cutter mesher smooth prism tetssi hexa mesh2block
    iparta_to_tetin igespost_exec ssish
} {
    set ${prog}_path not_found
    foreach p [list $bindir/$prog $autohex_root/icemcfd/$prog \
		   $bindir/$prog.exe $bindir/auto_$prog \
		   $autohex_root/icemcfd/auto_$prog $bindir/auto_$prog.exe \
		   $autohex_root/iges/$prog.exe \
		   $autohex_root/iges/${prog}_exec] {
	if [file exists $p] {
	    set ${prog}_path $p
	    break
	}
    }
    if {[set ${prog}_path] == "not_found"} {
	# puts "WARNING: no $prog binary"
    }
}

proc cad_get_menu {pos} {
    return ""  ;# need to move this to a better place
}

lappend source_dirs $auto_tool_dir
lappend source_dirs $app_dir

# Don't include: file_auto, view_auto, hardcopy_auto

set auto_tool_files {
    job_auto
    model_auto
    edit_auto
    interact_auto
    edit_subforms
    copymove_auto
    group_auto
    bocos_auto
    summary_auto
    anno_auto
    dxf
    fluent_uns
    part_auto
    misc
    undo_auto
    grid_auto
    grid_params_table
    mesher_auto
    global_auto
    tetra_auto
    hexa_auto
    meshface
    smoother_auto
    tetin_auto
    domainfile
    iges_autohex
    check_auto
    macro_auto
    hardcopy_auto
    units
    expression
    summary_sheet
    material
    unit_data
    pipe_auto
    cad_auto
    projlib_auto
    scripting_auto
    params_auto
}

load_fileset $auto_tool_dir $auto_tool_files ""

lappend prog_guide_files { scripting_auto }

foreach i { config problem solve grid config graph other uns } {
    set ${i}_params ""
}

#save_default_param_values

set model_container [model_container]
$model_container setval body_shape [shape_container -shtype container]
    
db_dirty off

# ---------------------------------------------

foreach p $graph_params {
    array set default_graph_$p [array get graph_$p]
}

foreach p [concat $config_params $config_default_params] {
    set default_config_param(job_$p) [set job_$p]
}

# ---------------------------

set generic_files {
    params_generic
    objects_generic
    form_auto
    file_generic
    polyduct
    obparams_generic
}

load_fileset $app_dir $generic_files ""

# Random variables that need to be initialized.

set tool_phase_info(params) {
    {params   button "Edit params"   0,1 "expression_edit"}
    {trials   button "Define trials" 0,2 "expression_trials"}
}

set tool_phase_info(model) {}

set r 0; set c 1
foreach ot $object_type_layout {
    if {$ot == "nl"} { incr r; set c 1; continue }
    
    set name $object_type_title($ot)
    if [info exists object_type_title_short($ot)] {
	set name $object_type_title_short($ot)
    } else {
	set object_type_title_short($ot) $name
    }
    lappend tool_phase_info(model) \
	[list $ot radiobutton $name $r,$c current_mtype $ot update_mtype]
    incr c
}
incr r

set model_extra_commands {
    {mesh     button      Mesh           2,1 "edit_grid 1 1 1 1" }
    {summary  button      "Summary"      2,2 "summary_form"}
    {groups   button      "Groups"       2,3 "coll_edit group"}
    {priority button      "Priorities"   2,4 "model_edit_priority"}
    {macro    menu        "Macros"       2,5 {
	{ command -label "Polygonal ducts" -command make_polyduct }
    } }
    {util    menu        "Utilities"       2,6 {
	{ command -label "Assign face families" \
	      -command assign_face_families }
	{ command -label "Check gaps" \
	      -command model_check }
	{ command -label "Fluid family" \
	      -command tetin_set_fluid_family }
    } }
}

foreach b $model_extra_commands {
    lappend tool_phase_info(model) $b
}

# Here is some junk that ought to get redefined eventually.

proc post_clear {} {}
proc ff_invalidate {} {}
