#!/bin/ksh ## ## SCRIPT NAME: stl2admesh_fillholes_ivview_bygui ## ## in $FEDIR/scripts ## where FEDIR=/apps/nns_com/fea ############################################################################# ## PURPOSE: 1) Run the ADMesh STL-file-fixer program on a specified STL file, ## to 'fill-holes' and do other pre-requisite fixes ('exact' and ## 'remove-unconnected'). Output an ASCII 'fixed' STL file. ## ## 2) Then 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. ## ##-------- ## This script was meant to try to fill in holes in a model that has been ## processed by the 'Decimator' 'demo' tesselation-reduction program --- ## which leaves many random holes in its (STL) output file. Unfortunately, ## it leaves too many large holes for ADMesh to deal with. ADMesh was ## apparently meant to fill 'sliver' gaps. ############################################################################# ## CALLED BY: ## '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 -> ## STL ... tools -> ## Run ADMesh to fill gaps in STL output ## ## And maybe in ## ## SGI Toolchest -> ## Division-Mockup -> ## '.bgf' file viewers, bgf toolchest -> ## ??? ############################################################################# ## MAINTENANCE HISTORY: ## Written by: Blaise Montandon 13jul2004 Based on the script ## 'divadm_bgf2dxf2iv_ivview_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 "STL file to 'fixed' SLA file to Inventor Viewer - Warning" \ ## -t " STL File Fixer-Viewer:" \ ## -t " " \ ## -t " This STL file fixer-viewer, based on translating an STL file to a" \ ## -t " 'filled-holes' SLA (ASCII STL) file and then translating" \ ## -t " 'fixed' SLA file to an Inventor '.iv' file and" \ ## -t " using the 'ivview' viewer, is UNAVAILABLE AT THIS TIME." \ ## -t " " \ ## -t " This viewer is based on using the public 'ADMesh'" \ ## -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 a given STL file." \ ## -t " Ref: man SlaToIv" \ ## -t "" \ ## -t " The 'temp.iv' file is put in local directory, /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="STL File Fixer-Viewer - via 'ADMesh', 'SlaToIv', & 'ivview'" export CONFIRM_TITLE VIEWER_3D="ivview" CONFIRM_TEXT="\ STL File Fixer-Viewer - via 'ADMesh' 'SlaToIv', & 'ivview': This STL 3D-data-file Fixer-Viewer utility 1) translates a given STL 3D geometry file to an ASCII STL (SLA) file, then 2) translates the SLA file, in ASCII Stereolithography File format, to a '.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 tesselated (triangulated) model in the '.iv' file. ------------ 1) The public 'ADMesh' translator utility is used to create an ASCII STL (SLA) file from a given STL 3D geometry (triangles) file. 2) The SGI-supplied 'SlaToIv' file translator utility is used to create a '.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 STL file. --------------- SELECTING FILES: A Directory-Navigator-AND-File-Selector GUI is used to present a list of STL 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. ------- A USAGE: This STL-fixer-viewer utility can be used to TRY to fill 'holes' in what is supposed to be a set of triangles enclosing a solid. It uses the ADMesh program. (ADMesh seems to be intended to fill 'sliver' gaps --- not fill in large missing triangles or large groups of missing triangles.) ADMesh, by default, performs the following 6 processes: 1) -e, --exact Check for perfectly matched edges. 2) -n, --nearby Find and connect nearby facets. Correct bad facets. 3) -u, --remove-unconnected Remove facets that have 0 neighbors. 4) -f, --fill-holes Add facets to fill holes. 5) -d, --normal-directions Check and fix direction of normals(ie cw, ccw). 6) -v, --normal-values Check and fix normal values. When it does the 'nearby' process, it uses the following 3 parameters: 2a) -t, --tolerance=tol Initial tolerance to use for nearby check = tol 2b) -i, --iterations=i Number of iterations for nearby check = i 2c) -m, --increment=inc Amount to increment tolerance after iteration=inc The default value for tolerance is the length of the shortest edge of the mesh. The default number of iterations is 2, and the default increment is 0.01% of the diameter of a sphere that encloses the entire mesh. This utility setup uses the defaults. Some experiments indicate that if the defaults do not work, it is unlikely that other variations will achieve a good 'filled-in' model --- without changing the logic in the ADMesh program. A good output SLA file is usually indicated by the 'Processing Statistics' Number of parts : 1 Backwards edges : 0 If you do not get these statistics, ADMesh probably did not create the output that you hoped for. ------------ OUTPUT FILES: The 'temp.sla' & 'temp.iv' files are put in 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.iv' (and/or 'temp.sla') if you need to save them for a while. ----------- QUICK START for 'ivview': 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.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 a binary or ASCII STL full FILENAME IN THE 'File Selection' FIELD -OR- click the FILTER button & SELECT AN STL FILE from the file listbox. Then click 'OK' to 1) translate (WITH FIXES) the STL file to an ASCII STL (SLA) file, 2) convert the SLA file to an (ASCII) Inventor '.iv' file, then 3) *VIEW* the '.iv' file WITH 'ivview'. -OR- click 'Cancel' to exit. Some STL files are in directories like ${SGI_SERVER}: $FEDIR/3d_tools/cyberware_3Dtools.dir/HUMANmodels ${SGI_SERVER}: $FEDIR/demos_stl ${VIZ_SERVER}: /division/VIZADM_DEVELOPMENT/Sample_data/ ${VIZ_SERVER}: /division/VIZADM_DEVELOPMENT/SESSION_WKG/viz/projects/NASACAVE/.../ Or perhaps you have STL files in ${THISHOST}: /local/scratch/$USER/ ${SGI_SERVER}: /data/subs/cae/$USER/ ${SGI_SERVER}: $HOME/ " ## /division/VIZADM_DEVELOPMENT/SESSION_WKG/BEM-NNSPMC-data/yard/emals/product/5004/grey/ ## ## /division/VIZADM_DEVELOPMENT/SESSION_WKG/BEM-NNSPMC-data/yard/island76/fuchsia_ax ## /division/VIZADM_DEVELOPMENT/SESSION_WKG/BEM-NNSPMC-data/yard/island76/green_ax/ ## /division/VIZADM_DEVELOPMENT/SESSION_WKG/BEM-NNSPMC-data/yard/island76/peach_ax/ ## /division/VIZADM_DEVELOPMENT/SESSION_WKG/BEM-NNSPMC-data/yard/island76/teal_ax/ ## ## /division/VIZADM_DEVELOPMENT/SESSION_WKG/viz/projects/NASACAVE/hpcdemo/magenta_ax/ ## /division/VIZADM_DEVELOPMENT/SESSION_WKG/viz/projects/NASACAVE/hpcdemo/maroon_ax/ ## /division/VIZADM_DEVELOPMENT/SESSION_WKG/viz/projects/NASACAVE/hpcdemo/pink_ax/ ## /division/VIZADM_DEVELOPMENT/SESSION_WKG/viz/projects/NASACAVE/hpcdemo/purple/ FILSEL_NUMLINES="17" ####################### ## SET FILE DIR & MASK. ####################### ## FOR TESTING: # FILSEL_MASK="$FEDIR/demos_stl/*" FILSEL_MASK="$FEDIR/3d_tools/cyberware_3Dtools.dir/HUMANmodels/*.s*" # FILSEL_MASK="$FEDIR/3d_tools/cyberware_3Dtools.dir/HUMANmodels/*.s*" # FILSEL_MASK="$FEDIR/demos_stl/*.s*" # FILSEL_MASK="/division/VIZADM_DEVELOPMENT/Sample_data/*.s*" # FILSEL_MASK="/division/VIZADM_DEVELOPMENT/SESSION_WKG/viz/projects/NASACAVE/hpcdemo/purple/*.s*" DIRTEMP=`dirname "$FILSEL_MASK"` if test ! -d $DIRTEMP then FILSEL_MASK="$HOME/*.s*" 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. ######################################################################### # # STL_CHECK=`file $FILEIN | grep "ascii text"` # # if test ! "$STL_CHECK" = "" # then # # xconfirm -c -header "'STL File Fixer-Viewer - Warning" -B DISMISS \ # -t "The file" \ # -t " $FILEIN" \ # -t "is not a 'text' file. " \ # -t " " \ # -t "The ADMesh utility program & translator" \ # -t "can create an ASCII STL (SLA) file from a binary STL 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}/*.s*" # FILSEL_MASK="${CURDIRNAME}/*" # export FILSEL_MASK # # # FILTER_AT_STARTUP=NO # # export FILTER_AT_STARTUP # # continue # # fi # ## END OF if test ! "$STL_CHECK" = "" ######################################################################### ## CHECK THAT THE STL FILE IS NOT SO BIG THAT 'ADMesh' will create ## such a big SLA file that 'SlaToIv' will have a problem translating ## it (exceeding in-memory-array-sizes or whatever). ######################################################################### STL_BYTES=`ls -l $FILEIN | awk '{print $5}'` STL_MEG=`echo "scale = 6; $STL_BYTES / 1000000" | bc -l` if test "$STL_BYTES" -gt 2500000 then GO_YN=`xconfirm -c -header "STL FILE SIZE - Warning" \ -b Proceed -B Exit \ -t "The file" \ -t " $FILEIN" \ -t "is big ($STL_MEG Megabytes). It is so big that 'ADMesh' will create" \ -t "such a big ASCII STL file (about 5 times bigger)" \ -t "that 'SlaToIv' will probably consume a lot of memory translating the" \ -t "SLA file into an '.iv' file." \ -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" \ -t "Proceed (AT THE RISK OF EXCEEDING VIRTUAL MEMORY ON HOST $THISHOST)." \ -icon warning` if test "$GO_YN" = "Exit" then exit fi fi ## END OF if test "$STL_BYTES" -gt 2500000 ######################################################################### ## TRANSLATE the STL file to an SLA file --- ## using the 'ADMesh' utility program. ## Some 'ADMesh' help info follows. ######################################################################### ## ## $ admesh-0.95-irix5.3.bin --help GIVES: ## ## ADMesh version 0.95 ## Copyright (C) 1995, 1996 Anthony D. Martin ## Usage: admesh-0.95-irix5.3.bin [OPTION]... file ## ## --x-rotate=angle Rotate CCW about x-axis by angle degrees ## --y-rotate=angle Rotate CCW about y-axis by angle degrees ## --z-rotate=angle Rotate CCW about z-axis by angle degrees ## --xy-mirror Mirror about the xy plane ## --yz-mirror Mirror about the yz plane ## --xz-mirror Mirror about the xz plane ## --scale=factor Scale the file by factor (multiply by factor) ## --translate=x,y,z Translate the file to x, y, and z ## --merge=name Merge file called name with input file ## -e, --exact Only check for perfectly matched edges ## -n, --nearby Find and connect nearby facets. Correct bad facets ## -t, --tolerance=tol Initial tolerance to use for nearby check = tol ## -i, --iterations=i Number of iterations for nearby check = i ## -m, --increment=inc Amount to increment tolerance after iteration=inc ## -u, --remove-unconnected Remove facets that have 0 neighbors ## -f, --fill-holes Add facets to fill holes ## -d, --normal-directions Check and fix direction of normals(ie cw, ccw) ## --reverse-all Reverse the directions of all facets and normals ## -v, --normal-values Check and fix normal values ## -c, --no-check Don't do any check on input file ## -b, --write-binary-stl=name Output a binary STL file called name ## -a, --write-ascii-stl=name Output an ascii STL file called name ## --write-off=name Output a Geomview OFF format file called name ## --write-dxf=name Output a DXF format file called name ## --write-vrml=name Output a VRML format file called name ## --help Display this help and exit ## --version Output version information and exit ## ## The functions are executed in the same order as the options shown here. ## So check here to find what happens if, for example, --translate and --merge ## options are specified together. The order of the options specified on the ## command line is not important. ## ## ... ## ... ## ## The default value for tolerance is the length of the shortest edge of the ## mesh. The default number of iterations is 2, and the default increment is ## 0.01% of the diameter of a sphere that encloses the entire mesh. ## ## ... ## ... ## ## Mesh Checking and Repairing Options ## =================================== ## ## '-e', '--exact' ## Check each facet of the mesh for its 3 neighbors. Since each facet is a ## triangle, there should be exactly 3 neighboring facets for every facet in ## the mesh. Since the mesh defines a solid, there should be no unconnected ## edges in the mesh. When this option is specified, the 3 neighbors of ## every facet are searched for and, if found, the neighbors are added to an ## internal list that keeps track of the neighbors of each facet. A facet ## is only considered a neighbor if two of its vertices EXACTLY match two of ## the vertices of another facet. That means that there must be 0 ## difference between the x, y, and z coordinates of the two vertices of the ## first facet and the two vertices of the second facet. ## ## Degenerate facets (facets with two or more vertices equal to each other) ## are removed during the exact check. No other changes are made to the ## mesh. An exact check is always done before any of the other checking and ## repairing options even if --exact isn't specified. There is one ## exception to this rule; no exact check needs to be done before the ## --normal-values option. ## ## '-n', '--nearby' ## '-t', '--tolerance=tol' ## '-i', '--iterations=i' ## '-m', '--increment=inc' ## Checks each unconnected facet of the mesh for facets that are almost ## connected but not quite. Due to round-off errors and other factors, it ## is common for a mesh to have facets with neighbors that are very close ## but don't match exactly. Often, this difference is only in the 8th ## decimal place of the vertices, but these facets will not show up as ## neighbors during the exact check. This option finds these nearby ## neighbors and it changes their vertices so that they match exactly. The ## exact check is alway done before the nearby check, so only facets that ## remain unconnected after the exact check are candidates for the nearby ## check. ## ## The --tolerance=tol option is used to specify the distance that is ## searched for the neighboring facet. By default, this value is set ## automatically by ADMesh to be the length of the shortest edge of the ## mesh. This value is used because it makes it unlikely for a facet that ## shouldn't be a neighbor to be found and matched as a neighbor. If the ## tolerance is too big, then some facets could end up connected that should ## definitely not be connected. This could create a "mobius part" that is ## not a valid solid. If this occurs, it can be seen by checking the value ## of "Backwards edges" that is printed after processing. (The number of ## backwards edges should be 0 for a valid solid.) ## ## The --iterations=i and --increment=inc options are used together to ## gradually connect nearby facets using progressively larger tolerances. ## This helps to prevent incorrect connects but can also allow larger ## tolerances to be used. The --iterations option gives the number of times ## that facets are checked for nearby facets, each time using a larger ## tolerance. The --increment=inc option gives the amount that the ## tolerance is increased after each iteration. The number specified by ## 'inc' is added to the tolerance that was used in the previous iteration. ## If all of the facets are connected, no further nearby checks will be ## done. ## ## '-f', '--fill-holes' ## ## Fill holes in the mesh by adding facets. This is done after the exact ## check and after nearby check (if any nearby check is done). If there are ## still unconnected facets, then facets will be added to the mesh, ## connecting the unconnected facets, until all of the holes have been ## filled. This is guaranteed to completely completely fix all unconnected ## facets. However, the resulting mesh may or may not be what the user ## expects. ## ## '-d', '--normal-directions' ## ## Check and fix if necessary the directions of the facets. This only deals ## with whether the vertices of all the facets are oriented clockwise or ## counterclockwise, it doesn't check or modify the value of the normal ## vector. Every facet should have its vertices defined in a ## counterclockwise order when looked at from the outside of the part. This ## option will orient all of the vertices so that they are all facing in the ## same direction. However, it it possible that this option will make all ## of the facets facet inwards instead of outwards. The algorithm tries to ## get a clue of which direction is inside and outside by checking the value ## of the normal vector so the chance is very good that the resulting mesh ## will be correct. However, it doesn't explicitly check to find which ## direction is inside and which is outside. In the future, I might write ## code to explicitly check for the inside and the outside, but until then, ## the current algorithm gets it right most of the time. ## ## '--reverse-all' ## Reverses the directions of all of the facets and normals. If the ## --normal-directions option ended up making all of the facets facet ## inwards instead of outwards, then this option can be used to reverse all ## of the facets. It is up to the user to determine if the facets are ## facing inwards and if they need reversing. In future versions of ADMesh, ## this process may be automated. This option also fixes and updates the ## normal vector for each facet. ## ## '-v', '--normal-values' ## Checks and fixes if necessary the normal vectors of every facet. The ## normal vector will point outward for a counterclockwise facet. The ## length of the normal vector will be 1. ## ## ... ## ## Examples ## ======== ## ## To perform all checks except for nearby, the following command line would be ## used: ## admesh --exact --remove-unconnected --fill-holes \ ## --normal-directions --normal-values sphere.stl ## ## Actually, since the exact check is required by ADMesh before ## remove-unconnected, and remove-unconnected is required before --fill-holes, ## the above command line could be shortened as follows with the same results: ## admesh --fill-holes --normal-directions --normal-values sphere.stl ## ## And again the same results could be achieved using the short options: ## admesh -fudev sphere.stl ## or ## admesh -fdv sphere.stl ## ## The following command lines do the same thing: ## admesh sphere.stl ## admesh -fundev sphere.stl ## admesh -f -u -n -d -e -v sphere.stl ## since the -fundev options are implied by default. To eliminate one of the ## checks, just remove the letter of the check to eliminate from the "word" ## 'fundev'. ## ## ... ## ## '-f', '--fill-holes' ## ## Fill holes in the mesh by adding facets. This is done after the exact ## check and after nearby check (if any nearby check is done). If there are ## still unconnected facets, then facets will be added to the mesh, ## connecting the unconnected facets, until all of the holes have been ## filled. This is guaranteed to completely completely fix all unconnected ## facets. However, the resulting mesh may or may not be what the user ## expects. ## ######################################################################### OUTFILE_SLA="${LOCDIR}/temp.sla" rm -f $OUTFILE_SLA /usr/sbin/xwsh -bg midnightblue -fg white \ -title 'ADMesh_msgs (Wait .... until ADMesh is done. To kill it or TO PROCEED, Close Me.)' \ -hold -icontitle 'ADMesh_msgs' \ -geom 80x38+620+350 \ -e /apps/nns_com/fea/3d_tools/stlb2stla.dir/admesh-0.95-irix5.3.bin \ -e \ -n \ -u -f -d -v \ -a $OUTFILE_SLA $FILEIN # -n -t2.0 -i40 -m0.1 \ # -n -t5.0 -i10 -m20.0 \ # -u -f -d -v \ ## -e, --exact Only check for perfectly matched edges ## -n, --nearby Find and connect nearby facets. Correct bad facets ## -t, --tolerance=tol Initial tolerance to use for nearby check = tol ## -i, --iterations=i Number of iterations for nearby check = i ## -m, --increment=inc Amount to increment tolerance after iteration=inc ## -u, --remove-unconnected Remove facets that have 0 neighbors ## -f, --fill-holes Add facets to fill holes ## -d, --normal-directions Check and fix direction of normals(ie cw, ccw) ## -v, --normal-values Check and fix normal values # -i10 -m50.0 --fill-holes \ SLA_BYTES=`ls -l $OUTFILE_SLA | awk '{print $5}'` SLA_MEG=`echo "scale = 6; $SLA_BYTES / 1000000" | bc -l` ######################################################################### ## 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 80x23+620+350 \ -e $EXE_SlaToIv "$OUTFILE_SLA" "$OUTFILE_IV" ## FOR TESTING: # set - ######################################################################### ## VIEW the Inventor file with 'ivview'. ######################################################################### IV_BYTES=`ls -l $OUTFILE_IV | awk '{print $5}'` IV_MEG=`echo "scale = 6; $IV_BYTES / 1000000" | bc -l` # VIEW_MODE=`xconfirm -c \ # -header "'ivview' of '.iv' file from STL 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 STL 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 $IV_MEG Megabytes. The size of the intermediate fixed-STL file $OUTFILE_SLA is $SLA_MEG Megabytes. The size of the initial STL file $FILEIN is $STL_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 $VIEW_PARM $OUTFILE_IV # ivview -t "iv of $FILEIN" $VIEW_PARM $OUTFILE_IV & ivview -t "iv of $FILEIN" $VIEW_PARM $OUTFILE_IV ## FOR TESTING: # set - ######################################################################## ## RETURN TO FILE-SELECTION PROMPT. ######################################################################## CURDIRNAME=`dirname "$FILEIN"` # FILSEL_MASK="${CURDIRNAME}/*" FILSEL_MASK="${CURDIRNAME}/*.s*" export FILSEL_MASK FILSEL_MSG="\ PASTE *ANOTHER* STL FILENAME ... or click FILTER and select a file (binary or ASCII). Then click 'OK' to 1) translate (WITH FIXES) to an '.SLA' file, then 2) convert the SLA file to an Inventor '.iv' file, then 3) *VIEW* the '.iv' file WITH 'ivview'. -OR- Click 'Cancel' to exit. Some STL files are in directories like ${SGI_SERVER}: $FEDIR/3d_tools/cyberware_3Dtools.dir/HUMANmodels ${SGI_SERVER}: $FEDIR/demos_stl ${VIZ_SERVER}: /division/VIZADM_DEVELOPMENT/Sample_data/ ${VIZ_SERVER}: /division/VIZADM_DEVELOPMENT/SESSION_WKG/viz/projects/NASACAVE/hpcdemo/purple/ " FILSEL_NUMLINES="11" # FILTER_AT_STARTUP=NO # export FILTER_AT_STARTUP FILSEL_GEOM="+600+300" export FILSEL_GEOM done ######################################################################## ## END OF prompting loop, for file name. ########################################################################