Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-10 07:49:33

0001 #!/bin/bash  
0002 usage(){ cat << EOU
0003 cxr.sh : basis for higher level render scripts using CSGOptiXRenderTest
0004 =========================================================================
0005 
0006 This is typically invoked via higher level scripts, see::
0007 
0008    ./cxr_demo.sh 
0009    ./cxr_solid.sh 
0010    ./cxr_view.sh 
0011    ./cxr_overview.sh 
0012 
0013 TODO: revive MOI=ALL controlled from a higher level script, 
0014 MOI=ALL creates an arglist file and uses the --arglist option 
0015 to create a sequence of renders at the positions specified in 
0016 the arglist all from a single load of the geometry.  
0017 So a single run creates multiple different snaps of different
0018 parts of a geometry.
0019 
0020 To copy the last jpg render into s5p publication folders rerun the commandline 
0021 with PUB=some_descriptive_string. 
0022 The last render will be opened and a publication path determined and the jpg copied to it. 
0023 To check the path to be used without doing the copy use PUB=1. 
0024 Examples::
0025 
0026    PUB=1                      EYE=1,0,0 ZOOM=1 ./cxr_overview.sh 
0027    PUB=simple_transform_check EYE=1,0,0 ZOOM=1 ./cxr_overview.sh 
0028 
0029 
0030 TODO: former support for "--arglist" "--solid_label" "--sizescale" "--size" needs rejig as no longer parse args
0031 
0032 EOU
0033 }
0034 
0035 cd $(dirname $(realpath $BASH_SOURCE))
0036 SDIR=$PWD
0037 
0038 msg="=== $BASH_SOURCE :"
0039 
0040 if [ -n "$CFNAME" ]; then
0041     echo $msg CFNAME $CFNAME is defined : this is used by cxr_geochain.sh and cxr_demo.sh 
0042     export CFBASE=/tmp/$USER/opticks/${CFNAME}    ## override CFBASE envvar only used when CFNAME defined, eg for demo geometry
0043     echo $msg CFNAME $CFNAME CFBASE $CFBASE OVERRIDING 
0044     if [ ! -d "$CFBASE/CSGFoundry" ]; then 
0045         echo $msg ERROR CFNAME override but no corresponding CSGFoundry directory $CFBASE/CSGFoundry 
0046         echo $msg TO CREATE NON-STANDARD geometries use \"gc \; GEOM=$(basename $CFNAME) ./run.sh\"  
0047         return 1
0048     fi
0049 else
0050     export ${GEOM}_CFBaseFromGEOM=$HOME/.opticks/GEOM/$GEOM
0051 fi 
0052 
0053 defarg="run"
0054 arg=${1:-$defarg}
0055 
0056 pkg=CSGOptiX
0057 bin=CSGOptiXRenderTest
0058 
0059 # defaults 
0060 emm=t0           # what to include in the GPU geometry : default to t0 ie ~0 which means everything 
0061 moi=sWaterTube   # should be same as lLowerChimney_phys
0062 eye=-1,-1,-1,1   # where to look from, see okc/View::home 
0063 top=i0           # hmm difficuly to support other than i0
0064 sla=             # solid_label selection 
0065 icam=0           # 0:perpective 1:orthographic 2:equirect (2:not supported in CSGOptiX(7) yet)
0066 tmin=0.1         # near in units of extent, so typical range is 0.1-2.0 for visibility, depending on EYE->LOOK distance
0067 zoom=1.0
0068 size=1280,720,1
0069 sizescale=1.5
0070 
0071 # [ "$(uname)" == "Darwin" ] && cvd=0    # only one GPU on laptop : BUT are usually just grabbing from remote
0072 
0073 export CVDLabel="CVD${CUDA_VISIBLE_DEVICES}" 
0074 
0075 export EMM=${EMM:-$emm}    # -e 
0076 export MOI=${MOI:-$moi}    # evar:MOI OR --arglist when MOI=ALL  
0077 export EYE=${EYE:-$eye}    # evar:EYE 
0078 export TOP=$top            # evar:TOP? getting TOP=0 from somewhere causing crash
0079 export SLA="${SLA:-$sla}"  # --solid_label
0080 export ICAM=${ICAM:-$icam} # evar:CAMERATYPE  NB caller script ICAM overrides
0081 export TMIN=${TMIN:-$tmin} # evar:TMIN
0082 export ZOOM=${ZOOM:-$zoom} 
0083 export SIZE=${SIZE:-$size} 
0084 export SIZESCALE=${SIZESCALE:-$sizescale} 
0085 
0086 
0087 
0088 # okc Composition/Camera::Camera needs CAMERATYPE integer 
0089 export CAMERATYPE=$ICAM     
0090 # SGLM needs string sname 
0091 case $ICAM in
0092   0) export CAM="perspective" ;;
0093   1) export CAM="orthographic" ;;
0094 esac
0095 
0096 
0097 export OPTICKS_GEOM=${OPTICKS_GEOM:-$MOI}  # "sweeper" role , used by Opticks::getOutPrefix   
0098 
0099 case $(uname) in 
0100    Darwin) optix_version=70000 ;;   ## HMM: assuming remote using that version
0101    Linux)  optix_version=$(CSGOptiXVersion 2>/dev/null) ;;
0102 esac
0103 
0104 
0105 # the OPTICKS_RELDIR and NAMEPREFIX defaults are typically overridden from higher level script
0106 nameprefix=cxr_${top}_${EMM}_${SIZE}_
0107 export NAMEPREFIX=${NAMEPREFIX:-$nameprefix}
0108 
0109 reldir=top_${TOP}_
0110 export OPTICKS_RELDIR=${OPTICKS_RELDIR:-$reldir}  
0111 ## TODO: the RELDIR is being ignored 
0112 
0113 # changed layout
0114 # 1. add GEOM/$GEOM at top 
0115 # 2. remove the CSGOptiX pkg above the bin
0116 #   N[blyth@localhost opticks]$ mv CSGOptiX/CSGOptiXRenderTest GEOM/V1J008/
0117 
0118 
0119 
0120 export PBAS=/tmp/$USER/opticks/  # NB TRAILING SLASH 
0121 export TMPDIR=${PBAS}GEOM/$GEOM
0122 export LOGDIR=$TMPDIR/$bin
0123 mkdir -p $LOGDIR 
0124 cd $LOGDIR 
0125 
0126 
0127 export OPTICKS_OUT_FOLD=${CFBASE:-$TMPDIR}/$bin/$CVDLabel/${optix_version}
0128 export OPTICKS_OUT_NAME=$MOI
0129 if [ -n "$SCAN" ]; then
0130     OPTICKS_OUT_NAME=$OPTICKS_OUT_NAME/$SCAN
0131 fi 
0132 export BASE=$OPTICKS_OUT_FOLD/$OPTICKS_OUT_NAME
0133 
0134 
0135 # Example BASE directory path for scan outputs 
0136 #      /tmp/blyth/opticks/GEOM/J_2024aug27/CSGOptiXRenderTest/CVD1/70500/ALL/scan-emm
0137 #
0138 # SEventConfig::OutDir 
0139 #    $OPTICKS_OUT_FOLD/$OPTICKS_OUT_NAME  (should be same as BASE)
0140 # 
0141 # SEventConfig::OutPath
0142 #    SEventConfig::OutDir()/stem... 
0143 #
0144 
0145 
0146 
0147 if [ -z "$SCAN" ]; then 
0148 
0149    vars="CUDA_VISIBLE_DEVICES EMM MOI EYE TOP SLA CAM TMIN ZOOM CAMERATYPE OPTICKS_GEOM OPTICKS_RELDIR SIZE SIZESCALE CFBASE OPTICKS_OUT_FOLD OPTICKS_OUT_NAME"
0150    for var in $vars ; do printf "%10s : %s \n" $var ${!var} ; done 
0151 
0152 fi 
0153 
0154 
0155 if [ -n "$DEBUG" ]; then 
0156     case $(uname) in 
0157        Darwin) GDB=lldb__ ;;
0158        Linux)  GDB=gdb    ;;
0159     esac
0160 fi 
0161 
0162 DIV=""
0163 [ -n "$GDB" ] && DIV="--" 
0164 
0165 
0166 render()
0167 {
0168    local msg="=== $FUNCNAME :"
0169 
0170    local log=$bin.log
0171    local cmd="$GDB $bin" 
0172 
0173    if [ -z "$SCAN" ]; then
0174       which $bin
0175       pwd
0176       echo ==== $BASH_SOURCE $FUNCNAME : $cmd
0177    fi 
0178 
0179    printf "\n\n\n$cmd\n\n\n" >> $log 
0180 
0181    eval $cmd
0182    local rc=$?
0183 
0184    printf "\n\n\nRC $rc\n\n\n" >> $log 
0185 
0186    if [ -z "$SCAN" ]; then
0187        echo ==== $BASH_SOURCE $FUNCNAME : $cmd : rc $rc
0188    fi
0189  
0190    return $rc
0191 }
0192 
0193 
0194 
0195 if [ "$arg" == "run" ]; then
0196 
0197     render 
0198 
0199 elif [ "$arg" == "grab" -o "$arg" == "open" -o "$arg" == "grab_open" ]; then 
0200 
0201     source $SDIR/../bin/BASE_grab.sh $arg 
0202 
0203 elif [ "$arg" == "jstab" ]; then 
0204 
0205     source $SDIR/../bin/BASE_grab.sh $arg 
0206 
0207 elif [ "$arg" == "pub" -o "$arg" == "list" ]; then 
0208 
0209     source $SDIR/../bin/BASE_grab.sh $arg 
0210 
0211 elif [ "$arg" == "info" ]; then 
0212 
0213     vars="BASH_SOURCE BASE TMPDIR LOGDIR NAMEPREFIX SDIR optix_version"
0214     for var in $vars ; do printf " %20s : %s \n" "$var" "${!var}" ; done
0215 fi 
0216