Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-09 10:47:17

0001 #!/usr/bin/env bash
0002 
0003 # Set the field separator to newline to handle filenames with spaces
0004 IFS=$'\n'
0005 
0006 #change to the diretory in which files are processed
0007 cd $1
0008 
0009 # Process .stl files
0010 for f in $(find . -type f -name "*.stl" ! -name "*_ASCII.stl"); do
0011     # Unset IFS to avoid issues within the loop
0012     unset IFS
0013     # Check if the STL file is binary or ASCII
0014     if grep -q 'solid' "$f"; then
0015         echo "$f is already an ASCII STL and should be with name ending _ASCII.stl ."
0016         # Process the STL file with stl_gdml.py
0017     else
0018         echo "Converting $f from binary to ASCII STL."
0019         python ../BinaryToASCII.py "$f"    
0020     fi
0021     # Reset IFS for the next iteration
0022     IFS=$'\n'
0023 done
0024 
0025 # Process the ASCII .stl files
0026 for f in $(find . -name '*_ASCII.stl'); do
0027     # Unset IFS to avoid issues within the loop
0028     unset IFS
0029     # Check if the STL file is binary or ASCII
0030     if grep -q 'solid' "$f"; then
0031         
0032         echo "Converting $f from ASCII STL to .gdml"
0033         python ../stl_gdml.py --x-offset -40.5 --y-offset -427.8  --z-offset 0.0  ../out.gdml "$f"
0034     else
0035         echo "$f is probably a binary STL without ASCII start token solid and should not have the _ASCII.stl name ending."  
0036     fi
0037     # Reset IFS for the next iteration
0038     IFS=$'\n'
0039 done
0040 
0041 # Unset IFS and disable filename expansion
0042 unset IFS
0043 set +f