#
# Script file for the scripting library (scrib)
#
# File: scrib/scripts/welding.tcl
#
# $Revision$ on $Date$
# 
# Copyright (c) 1993-2003 ICEM CFD Engineering
#
#--------------------------------------------------------------------

if ![info exists proc_scrib_data(export_dir)] {
    set proc_scrib_data(export_dir) [pwd]
}
#
# these should probably be changed....
#
if ![info exists proc_scrib_data(export_dir)] {
    set proc_scrib_data(export_dir) "."
} elseif ![file isdirectory $proc_scrib_data(export_dir)] {
    file mkdir $proc_scrib_data(export_dir)
}
set assembly_mesh [file join $proc_scrib_data(export_dir) [file root $proc_scrib_data(export_file)].uns]
set assembly_tin [file root $assembly_mesh].tin
#
set welded_mesh [file rootname $assembly_mesh]_welded.uns
set welded_tin  [file rootname $welded_mesh].tin
#
# ...assumptive
#
#------------------------------------
#
if ![info exists proc_scrib_data(welding_mode)] {
    mess "cannot run welding script without knowing welding_mode. please set it\n"
    return
} else {
    set mode $proc_scrib_data(welding_mode) ;# from app_*/config.tcl or gui-field
}

if ![info exists proc_scrib_data(welding_file)] {
    mess "cannot run welding script without knowing welding_file. please set it\n"
    return   
} else {
    set weldfile $proc_scrib_data(welding_file) ;# from gui-field
}

if [info exists proc_scrib_data(welding_report)] {
    set reportfile $proc_scrib_data(welding_report) ;# from gui-field
} else {
    set reportfile ""
}
if [info exists proc_scrib_data(welding_maxproject)] {
    set projection_max $proc_scrib_data(welding_maxproject) ;# from gui-field
} else {
    set projection_max 50
}
#
#-------------------------------------------------------
#
# load those; pid thing--may be unnecessary
#
ic_load_tetin [list "$assembly_tin"]
ic_load_unstruct $assembly_mesh
#
# do the welding
#
scrib_lib_welding_spot_main $mode $weldfile $welded_tin $projection_max $reportfile
#
# save the welded mesh
#
ic_save_unstruct $welded_mesh
