Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:17

0001 #!/bin/bash
0002 usage(){ cat << EOU
0003 SGLFW_SOPTIX_Scene_test.sh : triangulated raytrace and rasterized visualization
0004 =================================================================================
0005 
0006 Assuming the scene folder exists already::
0007 
0008     ~/o/sysrap/tests/SGLFW_SOPTIX_Scene_test.sh
0009 
0010 As this uses GL interop it may be necessary to select the display GPU, eg with::
0011 
0012     export CUDA_VISIBLE_DEVICES=1
0013 
0014 
0015 Bash args
0016 ------------
0017 
0018 info
0019    dump vars
0020 
0021 open
0022    write context file, use this to control where screenshots are copied to
0023 
0024 run
0025    run executable
0026 
0027 dbg
0028    run under gdb
0029 
0030 close
0031    delete context file
0032 
0033 
0034 ENVVAR notes
0035 --------------
0036 
0037 WH FULLSCREEN EYE LOOK UP TMIN ESCALE CAM VIZMASK
0038     view control envvars used by SGLM.h, details for some of them below
0039 
0040 VIZMASK
0041     control CSGSolid to display, see SGLM::is_vizmask_set and SOPTIX_Properties::visibilityMask
0042     examples::
0043 
0044          VIZMASK=0      # only global:0
0045          VIZMASK=0,1
0046          VIZMASK=t0     # mask global:0 (t0 means NOT 0)
0047          VIZMASK=t0,1   # mask global:0 and 1
0048 
0049 
0050 SGLFW__DEPTH
0051     enables download and saving of jpg depth maps together with ordinary screenshots
0052     see SGLFW::init_img_frame
0053 
0054 SOPTIX__HANDLE
0055     selects what to include in the OptiX geometry, not the OpenGL one,
0056     so must switch to the CUDA/OptiX render with C key to see effect of changes.
0057     As solids usually much smaller than full geometry will usually need to
0058     adjust the target frame, eg with::
0059 
0060         MOI=EXTENT:1000 SGLFW_SOPTIX_Scene_test.sh
0061 
0062 SOPTIX_Options__LEVEL
0063     SOPTIX logging level
0064 
0065 
0066 Non-CMake local build for development
0067 --------------------------------------
0068 
0069 This script used the CMake built binary.
0070 For a separate non-CMake built binary see::
0071 
0072     ~/o/sysrap/tests/SGLFW_SOPTIX_Scene_test_local.sh
0073 
0074 
0075 EOU
0076 }
0077 
0078 cd $(dirname $(realpath $BASH_SOURCE))
0079 
0080 name=SGLFW_SOPTIX_Scene_test
0081 bin=$name
0082 export SCRIPT=$name
0083 
0084 source $HOME/.opticks/GEOM/GEOM.sh
0085 [ -z "$GEOM" ] && echo $BASH_SOURCE FATAL GEOM $GEOM IS REQUIRTED && exit 1
0086 
0087 _CFB=${GEOM}_CFBaseFromGEOM
0088 if [ ! -d "${!_CFB}/CSGFoundry/SSim/scene" ]; then
0089    echo $BASH_SOURCE : FATAL GEOM $GEOM ${_CFB} ${!_CFB}
0090    exit 1
0091 fi
0092 
0093 source $HOME/.opticks/GEOM/EVT.sh 2>/dev/null  ## optionally sets EVT name and corresponding AFOLD BFOLD where event arrays are loaded from
0094 source $HOME/.opticks/GEOM/MOI.sh 2>/dev/null  ## optionally sets MOI envvar controlling initial viewpoint
0095 source $HOME/.opticks/GEOM/ELV.sh 2>/dev/null  ## optionally set ELV envvar controlling included/excluded LV by name
0096 source $HOME/.opticks/GEOM/SDR.sh 2>/dev/null  ## optionally configure OpenGL shader
0097 source $HOME/.opticks/GEOM/CUR.sh 2>/dev/null  ## optionally define CUR_ bash function
0098 
0099 logging()
0100 {
0101    type $FUNCNAME
0102    #export SGLM_LEVEL=4
0103 
0104    #export SScene__level=1
0105    #export SGLFW_Scene__DUMP=1
0106    #export SGLM__set_frame_DUMP=1
0107    #export SGLFW_SOPTIX_Scene_test_DUMP=1
0108    #export SOPTIX_SBT__initHitgroup_DUMP=1
0109    #export SOPTIX_Options__LEVEL=0
0110    #export SOPTIX_Scene__DUMP=1
0111 }
0112 [ -n "$LOG" ] && logging
0113 
0114 anim()
0115 {
0116    type $FUNCNAME
0117    export SGLM__init_time_DUMP=1
0118 }
0119 [ -n "$ANIM" ] && anim
0120 
0121 [ -n "$OPENGL" ] && export SGLFW_check__level=1
0122 
0123 
0124 
0125 if [ -f "$HOME/.opticks/GEOM/VUE.sh" ]; then
0126     source $HOME/.opticks/GEOM/VUE.sh
0127 else
0128 
0129     #wh=1024,768
0130     wh=2560,1440
0131 
0132     #fullscreen=0
0133     fullscreen=1
0134 
0135     #eye=0.1,0,-10
0136     #eye=-1,-1,0
0137     #eye=-10,-10,0
0138     #eye=-10,0,0
0139     #eye=0,-10,0
0140     #eye=-1,-1,0
0141     eye=0,1,0
0142 
0143     look=0,0,0
0144     up=0,0,1
0145 
0146     tmin=0.1
0147 
0148     #escale=asis
0149     escale=extent
0150 
0151     cam=perspective
0152     #cam=orthographic
0153 
0154     vizmask=t    # 0xff default, no masking
0155     #vizmask=t0  # 0xfe mask global, only instanced geometry in both OpenGL and OptiX renders
0156 
0157     export WH=${WH:-$wh}
0158     export FULLSCREEN=${FULLSCREEN:-$fullscreen}
0159     export EYE=${EYE:-$eye}
0160     export LOOK=${LOOK:-$look}
0161     export UP=${UP:-$up}
0162     export TMIN=${TMIN:-$tmin}
0163     export ESCALE=${ESCALE:-$escale}
0164     export CAM=${CAM:-$cam}
0165 
0166     ## VIZMASK may be ssst.sh ONLY ?
0167     export VIZMASK=${VIZMASK:-$vizmask}
0168 
0169     #export CSGOptiXRenderInteractiveTest__SGLM_DESC=1
0170     #export SGLFW__DEPTH=1   # dump _depth.jpg together with screenshots
0171 
0172     soptix__handle=-1  # default, full geometry
0173     #soptix__handle=0  #  only non-instanced global geometry
0174     #soptix__handle=1  #  single CSGSolid
0175     #soptix__handle=2  #
0176     export SOPTIX__HANDLE=${SOPTIX__HANDLE:-$soptix__handle}
0177 
0178     #export SOPTIX_Options__LEVEL=1
0179 
0180 fi
0181 
0182 
0183 
0184 _CUR=GEOM/$GEOM/$SCRIPT/$EVT
0185 
0186 
0187 allarg="info_open_dbg_run_close_touch"
0188 defarg="info_run"   # do not open context by default
0189 [ -n "$BP" ] && defarg="info_dbg"
0190 
0191 arg=${1:-$defarg}
0192 arg2=$2
0193 
0194 vars="BASH_SOURCE allarg defarg arg name bin GEOM _CUR"
0195 
0196 if [ "${arg/info}" != "$arg" ]; then
0197     for var in $vars ; do printf "%20s : %s\n" "$var" "${!var}" ; done
0198     printf "\n"
0199 fi
0200 
0201 if [ "${arg/dbg}" != "$arg" ]; then
0202     source dbg__.sh
0203     dbg__ $bin
0204     [ $? -ne 0 ] && echo $BASH_SOURCE : dbg error && exit 2
0205 fi
0206 
0207 if [ "${arg/open}" != "$arg" ]; then
0208     # open to define current context string which controls where screenshots are copied to
0209     CUR_open ${_CUR}
0210 fi
0211 
0212 if [ "${arg/run}" != "$arg" ]; then
0213     $bin
0214     [ $? -ne 0 ] && echo $BASH_SOURCE : run error && exit 3
0215 fi
0216 
0217 if [ "${arg/close}" != "$arg" ]; then
0218     # close to invalidate the context
0219     CUR_close
0220 fi
0221 
0222 if [ "$arg" == "touch"  ]; then
0223     if [ -n "$arg2" ]; then
0224         CUR_touch "$arg2"
0225     else
0226         echo $BASH_SOURCE:touch needs arg2 datetime accepted by CUR_touch eg "ssst.sh touch 11:00"
0227     fi
0228 fi
0229 
0230 exit 0
0231