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


#
# --> Get filenames for mesh and meshable_tetin
#
if {![info exists proc_scrib_data(dir)] || ("" == $proc_scrib_data(dir))} {
    set proc_scrib_data(dir) [pwd]
}
set proc_scrib_data(name) [file rootname [file tail $proc_scrib_data(name)]]
set interim_mesh  [file join $proc_scrib_data(wdir) [file tail ${proc_scrib_data(name)}]].uns
set interim_geom  [file join $proc_scrib_data(wdir) [file tail ${proc_scrib_data(name)}]].tin
set meshable_geom [file join $proc_scrib_data(wdir) [file tail ${proc_scrib_data(name)}]]_meshable.tin
set out_boco      [file join $proc_scrib_data(wdir) [file tail ${proc_scrib_data(name)}]].fbc
set export_file [file join $proc_scrib_data(export_dir) [file tail ${proc_scrib_data(name)}]].nas

#
# --> Load the meshable tetin and then it's mesh for editing.
#     Rather important to load the tetin first.
#
if ![file exists $meshable_geom] {
    mess "Cannot find the meshable geometry:\n$meshable_tetin\n" red
} else {
    ic_load_tetin [list "$meshable_geom"]
}
if ![file exists $interim_mesh] {
    mess "Cannot find the mesh:\n$interim_mesh!\n" red
} else {
    ic_uns_load $interim_mesh
}
if [file exists $out_boco] {
    ic_boco_load $out_boco
    # this will often/usually not be there, so don't sweat it if not here.
}
#
#--> Ensure the mesh and tetin families are synched...? --jka
#
scrib_lib_utils_ensure_same_families
#
# --> Put status to screen
#
set status 0
if {[ic_uns_is_loaded] && [ic_geo_is_loaded]} {
    set status_text "Loaded"
    set color black
    set extra ""
} else {
    set status 1
    set status_text "\nCould not load"
    set color red
    set extra "please scroll up for errors."
}
mess "$status_text both the geometry [file tail $meshable_geom] and\
	mesh [file tail $interim_mesh] for review and editing...$extra\n" $color
#
# --> Maybe do some display and quality stuff
#
if !$status {
    scrib_lib_exec_med_display_update
    ic_view home
}



