#!/bin/ksh ## ## SCRIPT NAME: clemson_iv2stl_run_ivview_bygui ## ## in $FEDIR/scripts ## where FEDIR=/apps/nns_com/fea ############################################################################# ## PURPOSE: 1) Run the Clemson 'iv2stl' program on a specified Inventor '.iv' ## file --- to create an ASCII-STL (.sla) file. ## ## Then, to visually check the STL file: ## 2) Uses the SGI-supplied '/usr/sbin/SlaToIv' SLA-to-Inventor file ## translator to create a '.iv' Inventor file from the SLA (ASCII STL) ## file. Ref: man SlaToIv ## ## 3) Uses the SGI-supplied Inventor viewer program, '/usr/sbin/ivview', ## to show the fixed-STL data as a shaded (or wire) image. ## ## This utility prompts for a fully-qualified STL input filename -- using ## a Tcl-Tk GUI interface for file navigation-and-selection. ## ############################################################################# ## CALLED BY: ## 'clemson_iv2stl_tools' toolchest startup script in $FEDIR/scripts ## actually, by 'clemson_iv2stl_tools.chestdef' in $FEDIR/scripts ## AND ## 'stltools' toolchest startup script in $FEDIR/scripts ## actually, by 'stltools.chestdef' in $FEDIR/scripts ## ## which is called by ## '3d_tools' script in $FEDIR/scripts ## actually, by '3d_tools.chestdef' in $FEDIR/scripts ## ## which is called by ## 'handytools' script in $FEDIR/scripts ## actually, by 'handytools.chestdef' in $FEDIR/scripts ## ## Site SGI toolchest-drawer path: ## ## SGI Toolchest -> ## HandyTools -> ## 3D AuxTools -> ## Clemson STL & Inventor tools -> ## Run 'iv2stl' (with demo input or yours) ## ## and ## ## SGI Toolchest -> ## HandyTools -> ## 3D AuxTools -> ## STL ... SteroLithography file toolchest (NNS-SGI) -> ## Run Clemson 'iv2stl' (with demo input or yours) ## ############################################################################# ## MAINTENANCE HISTORY: ## Written by: Blaise Montandon 14jul2004 Based on the script ## 'stl2admesh_fillholes_ivview_bygui' ## & 'simtec_stl2ivview_bygui' ## in $FEDIR/scripts ## Updated by: Blaise Montandon 02aug2004 Add (undocumented) '-t' title parm ## to 'ivview' call. ############################################################################# ############################################################################# ## Setup to allow running outside of the nnsFEAmenu system. ############################################################################# if test "$FEDIR" = "" then FEDIR="/apps/nns_com/fea" fi # . $FEDIR/scripts/clearnns ############################################################################# ## SAVE 'this hostname' for host-checks and form titles. ############################################################################# THISHOST=`hostname` SGI_SERVER="engprd00" VIZ_SERVER="engvis00" ######################################################################## ## Popup a message via 'xconfirm' --- a sample to use in case this ## utility is de-activated for a period --- or to provide an ## informational message via 'xconfirm' rather than 'confirm.tk', which ## follows. ######################################################################## ## ## xconfirm -c -B DISMISS \ ## -header "Inventor file to SLA file Translator & Viewer - Warning" \ ## -t " IV-to-SLA File Translator-Viewer:" \ ## -t " " \ ## -t " This Inventor (or VRML-1) file to SLA (ASCII-STL) file translator" \ ## -t " and viewer utility --- based on translating an Inventor file to a" \ ## -t " '.sla' file and then translating the '.sla' file back to a '.iv'" \ ## -t " file for viewing in the 'ivview' viewer, is" \ ## -t " UNAVAILABLE AT THIS TIME." \ ## -t " " \ ## -t " This utility is based on using the Clemson 'iv2stl'" \ ## -t " utility program and on using the SGI-supplied 'SlaToIv'" \ ## -t " SLA-to-Inventor file translator utility to create a '.iv' " \ ## -t " Inventor file from the output SLA file." \ ## -t " Ref: man SlaToIv" \ ## -t "" \ ## -t " The 'temp.sla' & 'temp.iv' files are put in local directory," \ ## -t " /local/scratch/$USER," \ ## -t " if possible, to keep down network traffic and give a little faster" \ ## -t " startup of large image files. (Alternative: user's home directory) " \ ## -t "Exiting." \ ## -icon warning > /dev/null ## ## exit ## ######################################################################## ######################################################################### ## INFORM THE USER ABOUT HOW THIS UTILITY WORKS --- ## via a pop-up message window (a foreground process) ## that can be dismissed when the user is ready to continue. ######################################################################### CONFIRM_TITLE="IV-&-VRML1-to-SLA Translator-Viewer - via 'iv2stl', 'SlaToIv', & 'ivview'" export CONFIRM_TITLE VIEWER_3D="ivview" CONFIRM_TEXT="\ IV (or VRML-1) -to-SLA Translator-Viewer - via 'iv2stl', 'SlaToIv', & 'ivview': This Inventor (or VRML-1) 3D-data-file Translator-Viewer utility 1) translates a given Open Inventor 3D geometry file (VRML-1 included) to an ASCII STL (SLA) file, then 2) translates the SLA file, in ASCII Stereolithography File format, to a temporary '.iv' file, in Open Inventor 2.0 format, then 3) uses the SGI-supplied 'ivview' viewer, to view a shaded or wireframe image of the triangulated SLA model data in the temporary '.iv' file. For comparison, the user-selected Inventor or VRML-1 file is also shown, optionally, in another 'ivview' window. ** NOTE: Since VRML-1 is a subset of the Open Inventor file format, this ** utility will convert VRML-1 files, as well as more general Open ** Inventor files, to ASCII-STL (SLA) files. --------------------------- Addtional info on steps 1-3: 1) The Clemson 'iv2stl' translator utility is used to create an ASCII STL (SLA) file from a given Inventor (or VRML-1) file. 2) The SGI-supplied 'SlaToIv' file translator utility is used to create a temporary '.iv' file from the SLA file. Reference: man SlaToIv 3) The SGI 'ivview' utility has 'thumb-wheels' to allow for quick zoom and rotation of the triangulated data of the Inventor file. Or you can spin the model with a quick drag of the mouse. Reference: man ivview Use MB3 (mouse button 3) to choose WIREFRAME DrawStyle from a POPUP MENU. You can use 'Options, Edit Background color...' to quickly change the background from BLACK to GRAY or WHITE or magenta or other colors. MB1 = rotate (trackball). MB2 = Panning. Click on '?' button for more help. 'ivview' is a very easy-to-use and easy-to-learn viewer, with an amazing amount of nice features in a small package. It generally takes 2 to 12 seconds to translate and show a small to medium sized Inventor or VRML-1 file. --------------- SELECTING FILES: A Directory-Navigator-AND-File-Selector GUI is used to present a list of Inventor or VRML-1 files, for example, in a /local/scratch/$USER directory. OR, instead of navigating & selecting with the GUI, you may paste a full filename from a list in another window. ------------ OUTPUT FILES: The 'temp.sla' & 'temp.iv' files are put in a local directory, /local/scratch/$USER, if possible. (Alternative: user's home directory.) The local files keep down network traffic and give faster file I/O when creating or processing these files. Furthermore, the local files help avoid accumulation of files in server directories. You can copy-rename 'temp.sla' (and/or 'temp.iv') if you decide to save it/them for a while. ----------- QUICK START for '$VIEWER_3D': Reference: man $VIEWER_3D ----------- The SGI '$VIEWER_3D' utility has 'thumb-wheels' to allow for quick zoom and rotation of the Inventor file 'polygon-ated' model data. Or you can spin the model with a quick drag of the mouse. MB1 = rotate ; MB2 = pan ; Ctl-MB2 = zoom --- You can use 'Options, Edit Background color...' to quickly change the background from BLACK to WHITE or GRAY or MAGENTA or other colors. --- FOR WIREFRAME DISPLAYS, you can use MouseButton3 on the graphics area, to get a popup menu. Then use the 'Draw Style' option to set the Draw mode to 'hidden line' and, for huge models, set the Move mode to 'bounding box (no depth)'. --- You can use the 'Preferences..' option of the MB3-popup menu to turn on 'Show point of rotation axes' --- so that it is clearer where the rotation is centered. (Increase the size of the axes to about 100 pixels, with the wheel.) If the model is not where you want it with respect to the center of rotation, you can move the model, with MB2 and Ctl-MB2. --- The popup menu 'Preferences...' option provides a dialog box that includes a check-button for 'clipping planes'. --- YOU: If you have suggestions for improvement of this utility, please inform NN SGI Visualization Applications Support --- like the author of this utility, Blaise Montandon at 0-2301. To continue, click the 'Proceed' button." export CONFIRM_TEXT CONFIRM_GEOM="+080+080" CONFIRM_MINSIZE="150 100" export CONFIRM_GEOM CONFIRM_MINSIZE # CONFIRM_COLOR="plum2" # CONFIRM_COLOR="#EEAEEE" # CONFIRM_COLOR="#CC99CC" # CONFIRM_COLOR="#996699" # CONFIRM_COLOR="#AA77AA" CONFIRM_COLOR="#C090C0" export CONFIRM_COLOR # REPLY=`$FEDIR/tkGUIs/confirm.tk PROCEED CANCEL` REPLY=`$FEDIR/tkGUIs/confirm_scroll.tk PROCEED CANCEL` if test "$REPLY" = "CANCEL" then exit fi ######################################################################### ## SET var LOCDIR to /local/scratch/$USER --- if possible --- ## otherwise to $HOME. Used below to hold temporary files, like ## the 'temp.sla' file and the 'temp.iv' Inventor file for viewing. ######################################################################### . $FEDIR/scripts/set_localuserdir ######################################################################### ## INITIALIZE a directory-navigator/file-selector, for the user ## to specify the input file. ######################################################################### FILSEL_MSG="\ PASTE an INVENTOR full-FILENAME IN THE 'File Selection' FIELD -OR- click the FILTER button & SELECT an INVENTOR file from the file listbox. Then click 'OK' to translate the INVENTOR or VRML-1 file 1) to an ASCII STL (SLA) file, then to a temporary '.iv' file, then 2) *VIEW* the temporary '.iv' file WITH 'ivview'. -OR- click 'Cancel' to exit. Some INVENTOR & VRML-1 files are in directories like ${SGI_SERVER}: $FEDIR/demos_iv ${SGI_SERVER}: $FEDIR/demos_vrml1 ${THISHOST}: /usr/share/data/models ${THISHOST}: /usr/share/data/models/vehicles (& other subdirs) Or perhaps your Inventor (or VRML-1) files in /local/scratch/$USER/ or $HOME " FILSEL_NUMLINES="16" ####################### ## SET FILE DIR & MASK. ####################### # FILSEL_MASK="$FEDIR/demos_iv/*" # FILSEL_MASK="$FEDIR/demos_iv/*.[ivw][vr]*" FILSEL_MASK="$FEDIR/demos_vrml1/*" # FILSEL_MASK="/usr/share/data/models/*" DIRTEMP=`dirname "$FILSEL_MASK"` if test ! -d $DIRTEMP then FILSEL_MASK="$HOME/*.[ivw][vr]*" fi export FILSEL_MASK FILSEL_MSG FILSEL_NUMLINES # FILTER_AT_STARTUP=YES # export FILTER_AT_STARTUP ######################################################################## ######################################################################## ## START OF PROMPTING LOOP, FOR FILE SELECTION. ######################################################################## ######################################################################## # while true while : do ######################################################################## ## GET NAME OF USER-SELECTED STL FILE. ######################################################################## FILEIN=`$FEDIR/tkGUIs/file_select_gui_ver2.tk` if test "${FILEIN}" = "" then # continue # break exit fi ######################################################################### ## CHECK THAT THE FILE IS NOT ASCII. ## IF ASCII, return to the file selector. ######################################################################### # # FILEIN_CHECK=`file $FILEIN | grep "ascii text"` # # if test ! "$FILEIN_CHECK" = "" # then # # xconfirm -c -header "'IV-to-SLA File Translator-Viewer - Warning" \ # -B DISMISS \ # -t "The file" \ # -t " $FILEIN" \ # -t "is not a 'text' file. " \ # -t " " \ # -t "The 'iv2stl' translator utility program can create an" \ # -t "ASCII STL (SLA) file from a binary or ASCII Inventor file." \ # -t "" \ # -t "Proceed or exit (Cancel)." \ # -icon warning > /dev/null # # ## -t "Exiting." \ # ## -icon warning > /dev/null # ## # ## exit # # ######################################################################## # ## RETURN TO FILE-SELECTION PROMPT. # ######################################################################## # # CURDIRNAME=`dirname "$FILEIN"` # # FILSEL_MASK="${CURDIRNAME}/*.[ivw][vr]*" # FILSEL_MASK="${CURDIRNAME}/*" # export FILSEL_MASK # # # FILTER_AT_STARTUP=NO # # export FILTER_AT_STARTUP # # continue # # fi # ## END OF if test ! "$FILEIN_CHECK" = "" ######################################################################### ## CHECK THAT THE INVENTOR FILE IS NOT SO BIG THAT 'iv2stl' will create ## such a big SLA file that 'SlaToIv' will have a problem translating ## it (exceeding in-memory-array-sizes or whatever). ######################################################################### FILEIN_BYTES=`ls -l $FILEIN | awk '{print $5}'` FILEIN_MEG=`echo "scale = 6; $FILEIN_BYTES / 1000000" | bc -l` FILEINBIG_BYTES=2500000 if test $FILEIN_BYTES -gt $FILEINBIG_BYTES then GO_YN=`xconfirm -c -header "INPUT FILE SIZE - Warning" \ -b Proceed -B Exit \ -t "The file" \ -t " $FILEIN" \ -t "is big ($FILEIN_MEG Megabytes). It is so big that 'iv2stl' MAY" \ -t "create such a big ASCII STL file (about 5 times bigger)" \ -t "that 'SlaToIv' MAY consume a lot of memory translating the" \ -t "SLA file into a temporary '.iv' file for viewing." \ -t "" \ -t "'SlaToIv' may 'struggle' with translating SLA files bigger than" \ -t "about 10 Meg to 20 Meg --- especially if you do not have a lot" \ -t "of available memory on your machine." \ -t "" \ -t "Exit --- OR Proceed (at the risk of EXCEEDING VIRTUAL MEMORY" \ -t "ON HOST $THISHOST --- if it is not equipped with much memory)." \ -icon warning` if test "$GO_YN" = "Exit" then exit fi fi ## END OF if test $FILEIN_BYTES -gt $FILEINBIG_BYTES ######################################################################### ## TRANSLATE the INVENTOR file to an SLA file --- ## using the 'iv2stl' utility program. ## Some 'iv2stl' help info follows. ######################################################################### ## ## Usage: ./iv2stl [-a ] -o outputFile inputFile ## ## -a : write ascii .stl files (default is binary) ## ## ######################################################################### OUTFILE_SLA="${LOCDIR}/temp.sla" rm -f $OUTFILE_SLA /usr/sbin/xwsh -bg midnightblue -fg white \ -title "iv2stl_msgs (WAIT .... until 'File saved' msg. To kill it or TO PROCEED, Close Me.)" \ -hold -icontitle 'iv2stl_msgs' \ -geom 80x8+620+350 \ -e /apps/nns_com/fea/3d_tools/clemson_iv2stl2vrml.dir/iv2stl.dir/iv2stl \ -a \ -o $OUTFILE_SLA $FILEIN SLA_BYTES=`ls -l $OUTFILE_SLA | awk '{print $5}'` SLA_MEG=`echo "scale = 6; $SLA_BYTES / 1000000" | bc -l` ######################################################################### ## IF the '.sla' FILE IS VERY SMALL. show a msg to user and ## return to file selector. ######################################################################### if test $SLA_BYTES -lt 100 then xconfirm -c -header "SLA OUTPUT FILE - Warning" \ -B Dismiss \ -t "The output '.sla' file" \ -t " $OUTFILE_SLA" \ -t "is very small. It is probably the case that the input file" \ -t "that you selected" \ -t " $FILEIN" \ -t "is not of a type supported by the 'iv2stl' program." \ -t "" \ -t "For example, wireframe models are not supported." \ -t "Generally the 3D data must be for a closed, solid model." \ -t "" \ -t "Try again or Cancel ..." \ -icon warning > /dev/null # -t "Exiting ..." \ # exit ######################################################################## ## RETURN TO FILE-SELECTION PROMPT. ######################################################################## CURDIRNAME=`dirname "$FILEIN"` # FILSEL_MASK="${CURDIRNAME}/*.[ivw][vr]*" FILSEL_MASK="${CURDIRNAME}/*" export FILSEL_MASK # FILTER_AT_STARTUP=NO # export FILTER_AT_STARTUP continue fi ## END OF if test $FILEIN_BYTES -gt $FILEINBIG_BYTES ######################################################################### ## TRANSLATE the '.sla' file to an Inventor file --- ## using 'SlaToIv'. Some 'SlaToIv' help info follows. ######################################################################### ## USAGE: /usr/sbin/SlaToIv ######################################################################### ## SLATOIV(1) SLATOIV(1) ## ## NAME ## SlaToIv - convert an SLA format file into an Open Inventor 2.0 file. ## ## SYNOPSIS ## ## ## DESCRIPTION ## SlaToIv converts an SLA formatted file into an Open Inventor 2.0 file. ## Copyright 1993 by Iowa State University. ## ## Specifies the name of the SLA file to read and convert. ## ## Specifies the name of the Open Inventor file to use for output. ## ## FILES ## /usr/Inventor/bin/SlaToIv Program file ## ######################################################################### OUTFILE_IV="${LOCDIR}/temp.iv" rm -f $OUTFILE_IV if test -f /usr/sbin/SlaToIv then EXE_SlaToIv="/usr/sbin/SlaToIv" else EXE_SlaToIv="$FEDIR/3d_tools/SGIiv.dir/bin/SlaToIv" fi ## FOR TESTING: # set -x /usr/sbin/xwsh -bg midnightblue -fg white \ -title 'SlaToIv_msgs (WAIT ... until SlaToIv is done. To kill it, Close Me.)' \ -icontitle 'SlaToIv_msgs' \ -geom 80x13+620+350 \ -e $EXE_SlaToIv "$OUTFILE_SLA" "$OUTFILE_IV" ## FOR TESTING: # set - ######################################################################### ## VIEW the Inventor file with 'ivview'. ######################################################################### IVTEMP_BYTES=`ls -l $OUTFILE_IV | awk '{print $5}'` IVTEMP_MEG=`echo "scale = 6; $IVTEMP_BYTES / 1000000" | bc -l` # VIEW_MODE=`xconfirm -c \ # -header "'ivview' of '.iv' file from SLA file" \ # -B Examiner -b Walk \ # -t "SELECT AN 'ivview' VIEW MODE:" \ # -t "" \ # -t "'Examiner' (virtual trackball) or 'Walk' ?" \ # -t "" \ # -t "Use the '?' button in 'ivview' to see navigation details of the" \ # -t "'Examiner' mode versus the 'Walk' mode --- as well as for two other" \ # -t "modes ( 'Fly' and 'Plane' ) that are not implemented in 'ivview'." \ # -icon question` CONFIRM_TITLE="'ivview' of '.iv' file from SLA file'" export CONFIRM_TITLE CONFIRM_TEXT="\ SELECT AN 'ivview' VIEW MODE: 1) 'Examiner' (virtual trackball) OR 2) 'Walk' ----------------------------------------------------------------------- The size of the ASCII '.iv' file $OUTFILE_IV is $IVTEMP_MEG Megabytes. The size of the intermediate ASCII-STL (SLA) file $OUTFILE_SLA is $SLA_MEG Megabytes. The size of the initial Inventor (or VRML-1) file $FILEIN is $FILEIN_MEG Megabytes. ----------------------------------------------------------------------- Use the '?' button in 'ivview' to see navigation details of the 'Examiner' mode versus the 'Walk' mode --- as well as info for two other modes ( 'Fly' and 'Plane' ) that are not implemented in 'ivview'." export CONFIRM_TEXT CONFIRM_GEOM="+080+080" CONFIRM_MINSIZE="150 100" export CONFIRM_GEOM CONFIRM_MINSIZE # CONFIRM_COLOR="plum2" # CONFIRM_COLOR="#EEAEEE" # CONFIRM_COLOR="#CC99CC" # CONFIRM_COLOR="#996699" # CONFIRM_COLOR="#AA77AA" # CONFIRM_COLOR="#C090C0" CONFIRM_COLOR="#F0C0F0" export CONFIRM_COLOR VIEW_MODE=`$FEDIR/tkGUIs/confirm.tk Examiner Walk Exit` # VIEW_MODE=`$FEDIR/tkGUIs/confirm_scroll.tk Examiner Walk Exit` if test "$VIEW_MODE" = "Exit" then exit fi VIEW_PARM="" if test "$VIEW_MODE" = "Walk" then VIEW_PARM="-w" fi ## FOR TESTING: # set -x # ivview $VIEW_PARM $OUTFILE_IV & ivview -t "iv of $FILEIN" $VIEW_PARM $OUTFILE_IV & # ivview $VIEW_PARM $OUTFILE_IV # ivview -t "iv of $FILEIN" $VIEW_PARM $OUTFILE_IV ## FOR TESTING: # set - ######################################################################### ## Ask the user whether they also want to see the original ## Inventor file with 'ivview'. ######################################################################### GO_YN=`xconfirm -c -header "View 'Original' file? - for comparison" \ -b No -B Yes \ -t "Do you want to view the 'original' Inventor or VRML-1 file" \ -t " $FILEIN" \ -t "with 'ivview'?" \ -t "" \ -t "Yes OR No." \ -icon warning` if test "$GO_YN" = "Yes" then # ivview -t "$FILEIN" $VIEW_PARM $FILEIN & ivview -t "$FILEIN" $VIEW_PARM $FILEIN fi ######################################################################## ## RETURN TO FILE-SELECTION PROMPT. ######################################################################## CURDIRNAME=`dirname "$FILEIN"` # FILSEL_MASK="${CURDIRNAME}/*.[ivw][vr]*" FILSEL_MASK="${CURDIRNAME}/*" export FILSEL_MASK FILSEL_MSG="\ PASTE *ANOTHER* INVENTOR or VRML-1 FILENAME ... or click FILTER and select a file. Then click 'OK' to 1) translate to a '.sla' file, then to a temporary '.iv' file, then 2) *VIEW* the temporary '.iv' file WITH 'ivview'. -OR- Click 'Cancel' to exit. Some INVENTOR & VRML-1 files are in directories like ${SGI_SERVER}: $FEDIR/demos_iv ${SGI_SERVER}: $FEDIR/demos_vrml1 ${THISHOST}: /usr/share/data/models ${THISHOST}: /usr/share/data/models/vehicles (& other subdirs) " FILSEL_NUMLINES="10" # FILTER_AT_STARTUP=NO # export FILTER_AT_STARTUP done ######################################################################## ## END OF prompting loop, for file name. ########################################################################