#!/bin/ksh ## ## SCRIPT NAME: cyberware_ply2dxf_run_bygui ## ## in $FEDIR/scripts ## where FEDIR=/apps/nns_com/fea ######################################################################## ## PURPOSE: To run the Cyberware 'ply2dxf' translator --- with a GUI ## Directory-Navigator/File-Selector positioned at sample ## directory(ies) of Ply files. The user can change the ## directory (and file mask) to use their own Ply files. ## ## The Cyberware 'ply2dxf' program can convert a PLY file into an ## AutoCAD DXF (Data eXchange Format) 3D-geometry-data file (ASCII). ## ## This utility prompts for a fully-qualified input filename -- using ## a Tcl-Tk GUI interface for file navigation-and-selection. ## ##-------- ## Example Usage: ## This script was initially intended to give a quick way to convert Ply ## files, like sample human-models created by Cyberware 3D scanners, to ## DXF files that can then be converted to Division vdi-and-bgf Viz files, ## via the Division 'dxf2vdi' utility program. ## ## Also, the (ASCII) DXF file can be converted to an Inventor file, using the ## SGI-supplied 'DxfToIv' utility program. Then the Inventor file can be ## decimated (polygon reduced) via the Jade interactive decimator --- and ## then converted to Division vdi-and-bgf files via the Clemson 'iv2stl' ## program and via the Division 'stl2vdi' translator. ## See script 'divadm_dxf2vdi_bygui' ## which is similar to 'divadm_stl2vdi_bygui'. ## ## Ref: www..cyberware.com ######################################################################## ## CALLED BY: 'cyberware3D_tools' script in $FEDIR/scripts ## actually, by 'cyberware3D_tools.chestdef' in $FEDIR/scripts ## ## which is called by ## '3d_tools' script in $FEDIR/scripts ## actually, by '3d_tools.chestdef' ## ## 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 -> ## Cyberware 3D translators,viewer toolchest -> ## Run 'ply2dxf' (with demo input or yours) ## ######################################################################## ## MAINTENANCE HISTORY: ## Written by: Blaise Montandon 29jul2004 Based on scripts ## 'cyberware_ply2iv_run_bygui' ## and 'divadm_bgf2dxf2iv_ivview_bygui' ## in $FEDIR/scripts ## Updated by: Blaise Montandon 29jul2004 ######################################################################## ############################################################################# ## 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 -header "'ply2dxf' File Translator - Warning" -B DISMISS \ ## -t "'ply2dxf' File Translator:" \ ## -t " " \ ## -t " This 'ply2dxf' Ply file translator utility is UNAVAILABLE" \ ## -t " AT THIS TIME." \ ## -t " " \ ## -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="'ply2dxf' File Translator" export CONFIRM_TITLE CONFIRM_TEXT="\ Ply File Translator - 'ply2dxf': This 3D geometry data translator utility uses the Cyberware 'ply2dxf' translator, to convert a Ply file to a DXF 'polygonal format' file (ASCII). Ply files are used by Cyberware to store data gathered by their 3D scanners. Reference: www.cyberware.com This utility provides you names of one or more directories of 'demo' Ply files. But you can specify your own directories of Ply files. ------------------- The PLY file format: ------------------- The Ply format is a relatively simple 3D file format, developed at Stanford University, that can be translated easily to other, industry-standard file formats. For details on the PLY file format, see the Stanford Graphics Lab at http://www.www-graphics.stanford.edu/ . The Ply format is rather unusual in that the top lines of a Ply file appear to be 'pure ASCII text', while the bottom of the file is 'binary' data. ---------------------------------- Cyberware Description of 'ply2dxf' : ---------------------------------- Used to convert a PLY file into a DXF format file. [ASCII] Usage: ply2dxf [-h] [-f] [-v] infile.ply outfile.dxf Variables: -h: Display help message -f: Output 3DFACE entities -v: Verbose infile.ply: PLY file for input outfile.dxf: .dxf output file --------------- SELECTING FILES: --------------- A Directory-Navigator-AND-File-Selector GUI is used to present a list of Ply 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 --- into the 'File Selection:' entry field in the file-selector GUI. --- The file-selector GUI returns after each translation, so you can quickly convert a batch of PLY files. Simply click the 'Cancel' button on the file-selector GUI when you are finished translating files. ------------ OUTPUT FILES: ------------ The (ASCII) DXF output file, 'temp.dxf', is put in a local directory, /local/scratch/$USER, if possible. (Alternative: user's home directory.) The use of a local directory keeps down network traffic and gives faster file I/O when creating and using the DXF files. Furthermore, putting the output files 'locally' helps avoid accumulation of files in server directories. If you are doing a batch of translations, you can rename the 'temp.dxf' file before doing the next translation --- say by using 'mv' in a 'winterm' window. (Typically, there may be only one or a few in a batch of translations that you would really want to save to a unique name.) You can copy or move the new DXF file(s) --- if you need to save them for a while in a file-system that is backed up --- for example, 'mv' to a /data/cvn78/cae/$USER directory. ---------------------------------- VIEWING THE INVENTOR FILE CONTENTS: ---------------------------------- You can use the SGI-supplied 'perfly' 3D file viewer utility, to view the 3D geometry contents of the DXF file. Alternatively, you can use the SGI-supplied 'DxfToIv' utility to convert the (ASCII) DXF file to an Inventor file, and then use the 'ivview' command to dynamically view the Inventor file of polygon data. In fact, the 'DxfToIv' & 'ivview' programs are built into this utility --- to facilitate immediate, dynamic, graphical viewing of the contents of the DXF file that is created from a PLY file. For a PLY -> DXF -> Inventor file containing about 100,000 triangles, it may take more than 30 seconds for the shaded image to appear in the 'ivview' graphics window --- and for the function buttons and 'thumbwheels' to appear on the perimeter of the graphics window. --- Alternatively, another 'direct' DXF viewer, besides 'perfly', is the SIM (Systems in Motion, Norway) 'VRMLview' program. Example site SGI toolchest-drawer path to 'VRMLview': SGI Toolchest -> Handy Tools -> 3D AuxTools -> VMRL-1&2 & DXF & 3DS ... 'VRMLview' toolchest -> Start 'VRMLview 3.0' (on demo input or yours) Example site SGI toolchest-drawer path to 'perfly': SGI Toolchest -> Handy Tools -> 3D AuxTools -> STL,IV,DXF,3DS,FLT ... 'perfly' viewer, converte toolchest -> STARTUP MENU for 'perfly' & related EXECUTABLES -> START 'perfly' (on demo input or yours) --- Another option is to read an Inventor file, created by 'DxfToIv', into the 'Jade' interactive file decimator (polygon reducer) GUI-based utility. That utility has an interface that looks like the 'ivview' GUI, but with TWO graphics windows -- for the input Inventor file and for the 'decimated' version, which can be written to a new Inventor file. Example site SGI toolchest-drawer path to 'Jade': SGI Toolchest -> Handy Tools -> 3D AuxTools -> Poly Reducers -> 'Jade' polygon reducer toolchest ------------------------------------ EXAMPLE USE OF THIS 'ply2dxf' UTILITY, with 'Jade', to create 'Division' models: ------------------------------------ This utility could give a quick way to convert a Ply file, like a human-model created by Cyberware 3D scanners, to an Inventor file, via 'DxfToIv'. The Inventor file can be decimated (polygon reduced) via the 'Jade' interactive decimator --- and then converted to 'Division' vdi-and-bgf files via the Clemson 'iv2stl' program and via the Division 'stl2vdi' translator. --- 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. Is used below to name temporary files, like ## the 'temp.dxf' file, created from the 'ply2dxf' translator. ######################################################################### . $FEDIR/scripts/set_localuserdir ######################################################################### ## INITIALIZE a directory-navigator/file-selector, for the user ## to specify the input file. ######################################################################### if test "$DIR_CYBERWARE" = "" then DIR_CYBERWARE="$FEDIR/3d_tools/cyberware_3Dtools.dir" fi FILSEL_MSG="\ PASTE a PLY FILENAME in the 'File Selection:' FIELD -OR- click the FILTER button & SELECT a PLY file from the file listbox. Then click 'OK' to translate the PLY FILE with 'ply2dxf' --- and to convert the (ASCII) DXF to Inventor and view the Inventor file with 'ivview'. -OR- click 'Cancel' to exit. Some Ply files are in directories like ${SGI_SERVER}: $DIR_CYBERWARE/HUMANmodels/ ${SGI_SERVER}: $DIR_CYBERWARE/SAMPLEinout.dir/ Or perhaps your Ply files are in ${THISHOST}: /local/scratch/$USER/ ${SGI_SERVER}: $HOME/ ${SGI_SERVER}: /data/cvn78/cae/$USER/ ${VIZ_SERVER}: /division/.../.../ " # $DIR_CYBERWARE/SAMPLEinout.dir/ # $FEDIR/demos_ply/ FILSEL_NUMLINES="15" ####################### ## SET FILE DIR & MASK. ####################### ## FOR TESTING: # FILSEL_MASK="$FEDIR/demos_ply/*.ply" FILSEL_MASK="$DIR_CYBERWARE/HUMANmodels/*.ply*" # FILSEL_MASK="$DIR_CYBERWARE/HUMANmodels/*.ply*" # FILSEL_MASK="$DIR_CYBERWARE/SAMPLEinout.dir/*.ply*" # FILSEL_MASK="$FEDIR/demos_ply/*.ply*" DIRTEMP=`dirname "$FILSEL_MASK"` if test ! -d "$DIRTEMP" then if test -d "$LOCDIR" then FILSEL_MASK="${LOCDIR}/*.ply*" else FILSEL_MASK="$HOME/*.ply*" fi 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 Ply FILE. ##################################################################### FILEIN=`$FEDIR/tkGUIs/file_select_gui_ver2.tk` if test "${FILEIN}" = "" then # continue # break exit fi ######################################################################## ## CHECK THAT THE SELECTED FILE IS probably a Ply file (binary). ## IF NOT, return to the file selector. ######################################################################## FILE_TYPE=`file "$FILEIN"` ASCII_MATCH=`echo "$FILE_TYPE" | grep "ascii text"` if test ! "$ASCII_MATCH" = "" then REPLY=`xconfirm -c -header "'ply2dxf' File Translator - Warning" \ -b Proceed -B GoBack \ -t "The file" \ -t " $FILEIN" \ -t "is not a binary file. File type:" \ -t " " \ -t "$FILE_TYPE" \ -t " " \ -t "Proceed (to try ply2dxf anyway) or GoBack (try another or Cancel)." \ -icon warning` ############################################################ ## RETURN TO FILE-SELECTION PROMPT. ############################################################ if test "$REPLY" = "GoBack" then CURDIRNAME=`dirname "$FILEIN"` FILSEL_MASK="${CURDIRNAME}/*.ply*" export FILSEL_MASK # FILTER_AT_STARTUP=NO # export FILTER_AT_STARTUP continue fi fi ## END OF if test ! "$ASCII_MATCH" = "" ######################################################################### ## PREPARE LOCAL 'OUTLIST' FILENAME for list of DXF files in $LOCDIR. ######################################################################### . $FEDIR/scripts/set_localoutlist rm -f $OUTLIST PLY_BYTES=`ls -l $FILEIN | awk '{print $5}'` PLY_MEG=`echo "scale = 6; $PLY_BYTES / 1000000" | bc -l` ######################################################################### ## TRANSLATE the Ply file with 'ply2dxf'. ######################################################################### ## Description of 'ply2dxf': ## ## Used to convert a PLY file into a DXF format file. [ASCII] ## ## Usage: ## ply2dxf [-h] [-f] [-v] infile.ply outfile.dxf ## ## Variables: ## -h: Display help message ## -f: Output 3DFACE entities ## -v: Verbose ## infile.ply: PLY file for input ## outfile.dxf: .dxf output file ######################################################################### OUTFILE_DXF="${LOCDIR}/temp.dxf" rm -f $OUTFILE_DXF ## FOR TESTING: # set -x /usr/sbin/xwsh -bg midnightblue -fg white \ -title 'ply2dxf_msgs (WAIT .... until ply2dxf is done. To kill it or TO PROCEED, Close Me.)' \ -icontitle 'ply2dxf_msgs' \ -geom 80x18+620+350 \ -e $DIR_CYBERWARE/bin/ply2dxf -v $FILEIN $OUTFILE_DXF # -hold \ ## FOR TESTING: # set - ######################################################################## ## PUT a list of LOCDIR '.dxf' files in $OUTLIST. ######################################################################## echo " FILES with a '.dxf' suffix IN $LOCDIR: " > $OUTLIST ls -l $LOCDIR | grep '\.dxf.*$' >> $OUTLIST echo " ------------------------------ File $OUTFILE_DXF was created from file $FILEIN by script $0 ------------------------------ VIEWING CONTENTS OF DXF FILES: You can use the SGI-supplied 'perfly' 3D file viewer utility, to view the 3D geometry contents of the (ASCII) DXF file. Alternatively, you can use the SGI-supplied 'DxfToIv' utility to convert the (ASCII) DXF file to an Inventor file, and then user the 'ivview' command to dynamically view the Inventor file of polygon data. In fact, the 'DxfToIv' & 'ivview' programs are built into this utility --- to facilitate immediate, dynamic, graphical viewing of the contents of the (ASCII) DXF file that is created from a PLY file. For a PLY -> DXF -> Inventor file containing about 100,000 triangles, it may take more than 30 seconds for the shaded image to appear in the 'ivview' graphics window --- and for the function buttons and 'thumbwheels' to appear on the perimeter of the graphics window. --- Alternatively, another 'direct' DXF viewer, besides 'perfly', is the SIM (Systems in Motion, Norway) 'VRMLview' program. Example site SGI toolchest-drawer path to 'VRMLview': SGI Toolchest -> Handy Tools -> 3D AuxTools -> VMRL-1&2 & CXF & 3DS ... 'VRMLview' toolchest -> Start 'VRMLview 3.0' (on demo input or yours) Example site SGI toolchest-drawer path to 'perfly': SGI Toolchest -> Handy Tools -> 3D AuxTools -> STL,IV,DXF,3DS,FLT ... 'perfly' viewer, converte toolchest -> STARTUP MENU for 'perfly' & related EXECUTABLES -> START 'perfly' (on demo input or yours) --- Another option is to read an Inventor file, created by 'DxfToIv', into the 'Jade' interactive file decimator (polygon reducer) GUI-based utility. That utility has an interface that looks like the 'ivview' GUI, but with TWO graphics windows -- for the input Inventor file and for the 'decimated' version, which can be written to a new Inventor file. Example site SGI toolchest-drawer path to 'Jade': SGI Toolchest -> Handy Tools -> 3D AuxTools -> Poly Reducers -> 'Jade' polygon reducer toolchest ------------------------------------- EXAMPLE USE OF THIS 'ply2dxf' UTILITY, with 'Jade', to create 'Division' models: ------------------------------------- This utility could give a quick way to convert a Ply file, like a human-model created by Cyberware 3D scanners, to an Inventor file, via 'DxfToIv'. Then the Inventor file can be decimated (polygon reduced) via the 'Jade' interactive decimator --- and then converted to 'Division' vdi-and-bgf files via the Clemson 'iv2stl' program and via the Division 'stl2vdi' translator. -------------------------------------- " >> $OUTLIST ######################################################################## ## SHOW $OUTLIST. ######################################################################## WINX="10" WINY="10" export WINX WINY $FEDIR/scripts/shofil $OUTLIST ######################################################################## ## CONVERT (ASCII) DXF file to a binary Inventor file, $OUTFILE_IV --- ## for viewing with 'ivview'. ######################################################################## ## Use 'DxfToIv'. Some 'DxfToIv' help info follows. ######################################################################### ## DxfToIv (1) - converts an Autodesk Data Exchange File format (.DXF) ## file to Open Inventor 2.0 format ######################################################################### ## $ /usr/sbin/DxfToIv -h ## ## ____________________________________________________________________________ ## DxfToIv Version 1.0 7/26/95 ## Copyright (c) 1995 Abaco Systems, Inc. and Silicon Graphics, Inc. ## ## Call with questions Tel: (510) 494-0690 ## Fremont, CA, USA Fax: (510) 494-0893 or email: 3dsoftware@abaco.com ## ____________________________________________________________________________ ## ## DxfToIv converts Dxf wire files to Inventor 2.0 files. ## ## DxfToIv [-h] [-b] [-v] [-q] [- | ] ## Where ## ## Dxf wire file to convert. If is absent or '-' input is taken ## from stdin. ## ## ## Inventor file. If is absent output goes to stdout. ## ## -h ## Display this usage guide ## ## -b ## Output the file in Open Inventor binary file format. Default is ASCII. ## ## -v ## trace operation of the converter. ## ## -q ## No output on screen ######################################################################### DXF_BYTES=`ls -l $OUTFILE_DXF | awk '{print $5}'` DXF_MEG=`echo "scale = 6; $DXF_BYTES / 1000000" | bc -l` OUTFILE_IV="${LOCDIR}/temp.iv" rm -f $OUTFILE_IV if test -f /usr/sbin/DxfToIv then EXE_DxfToIv="/usr/sbin/DxfToIv" else EXE_DxfToIv="$FEDIR/3d_tools/SGIiv.dir/bin/DxfToIv" fi ## FOR TESTING: # set -x /usr/sbin/xwsh -bg midnightblue -fg white \ -title 'DxfToIv_msgs (WAIT ... DxfToIv takes time on a large file. To kill it, Close Me.)' \ -icontitle 'DxfToIv_msgs' \ -geom 80x23+620+350 \ -e $EXE_DxfToIv -v -b "$OUTFILE_DXF" "$OUTFILE_IV" ## FOR TESTING: # set - if test ! -f "$OUTFILE_IV" then xconfirm -c -B DISMISS \ -header "'.bgf' Viewer - ERROR" \ -t "The '.iv' output file" \ -t "" \ -t " $OUTFILE_IV" \ -t "" \ -t "has NOT been created." \ -t "" \ -t "Exiting ..." \ -icon warning > /dev/null exit fi ######################################################################### ## VIEW the Inventor file $OUTFILE_IV with 'ivview'. ######################################################################### IV_BYTES=`ls -l $OUTFILE_IV | awk '{print $5}'` IV_MEG=`echo "scale = 6; $IV_BYTES / 1000000" | bc -l` CONFIRM_TITLE="'ivview' of '.iv' file from '.bgf file'" export CONFIRM_TITLE CONFIRM_TEXT="\ SELECT AN 'ivview' VIEW MODE: 1) 'Examiner' (virtual trackball) OR 2) 'Walk' ----------------------------------------------------------------------- The size of the binary '.iv' file $OUTFILE_IV is $IV_MEG Megabytes. The size of the intermediate ASCII '.dxf' file $OUTFILE_DXF is $DXF_MEG Megabytes. The size of the binary '.ply' file $FILEIN is $PLY_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 ## FOR TESTING: # set - ######################################################################## ## RETURN TO FILE-SELECTION PROMPT. ######################################################################## sleep 4 CURDIRNAME=`dirname "$FILEIN"` # FILSEL_MASK="${CURDIRNAME}/*.p*" # FILSEL_MASK="${CURDIRNAME}/*" FILSEL_MASK="${CURDIRNAME}/*.ply*" export FILSEL_MASK FILSEL_MSG="\ SELECT *ANOTHER* PLY FILE ... for *TRANSLATING* WITH 'ply2dxf' --- and converting DXF to Inventor and viewing the Inventor file with 'ivview'. -OR- click 'Cancel' to exit. Some PLY files are in directories like ${SGI_SERVER}: $DIR_CYBERWARE/HUMANmodels/ ${SGI_SERVER}: $DIR_CYBERWARE/SAMPLEinout.dir/ Or perhaps your Ply files are in ${THISHOST}: /local/scratch/$USER/ ${SGI_SERVER}: $HOME/ ${SGI_SERVER}: /data/cvn78/cae/$USER/ ${VIZ_SERVER}: /division/.../.../ " # $DIR_CYBERWARE/SAMPLEinout.dir/ # $FEDIR/demos_ply/ FILSEL_NUMLINES="12" # FILTER_AT_STARTUP=NO # export FILTER_AT_STARTUP FILSEL_GEOM="+600+400" # FILSEL_GEOM="+700+500" export FILSEL_GEOM done ######################################################################## ## END OF prompting loop, for file name. ########################################################################