Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add geometry drawing scripts #52

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

add geometry drawing scripts #52

wants to merge 12 commits into from

Conversation

jdkio
Copy link
Contributor

@jdkio jdkio commented Feb 27, 2025

Adds draw_geometry.py and draw_all.sh. The --axis option is useful but it's a bit finicky. Sometimes the axis doesn't align with the world properly. I've given up trying to fix it. By default it's off

./draw_all.sh 
Usage ./draw_all --filename <gdml file> + any additional args
Automatically draws all default views
Here's the output of python draw_geometry.py --help:
usage: draw_geometry.py [-h] --filename FILENAME [--outdir OUTDIR] [--outfilename OUTFILENAME] [--view VIEW] [--color COLOR]
                        [--draw_air] [--preview] [--height HEIGHT] [--width WIDTH] [--scale SCALE] [--axis] [--translate VALUE]
                        [--matrix MATRIX] [--verbose]

Process geometry files with optional transformations and visualization settings.

optional arguments:
  -h, --help            show this help message and exit
  --filename FILENAME   Input geometry filename (required).
  --outdir OUTDIR       Output directory (defaults to 'output').
  --outfilename OUTFILENAME
                        Custom output filename (defaults to view_name.png or custom_matrix.png).
  --view VIEW           Draw built-in view (xz, xz_wide, xz_zoom, yz, yz_wide, yz_zoom, lar_top, lar_side, tms_top, tms_side, sand_top,
                        sand_side, rock_top, rock_side)
  --color COLOR         Color function to use. (density, density_bw, random, material, scintillator)
  --draw_air            Whether to draw air/vac. Normally white
  --preview             Draw 1/4th size preview image (16x faster)
  --height HEIGHT       Image height
  --width WIDTH, -w WIDTH
                        Image width
  --scale SCALE         Scale image
  --axis                Whether to draw the axis (experimental, will make image more square)
  --translate VALUE, -t VALUE
                        Translate the 3rd axis by this amount. Useful for making slices. (e.g., '1m', '100cm', 't-0.5mm'). Defaults to
                        cm if no unit is given.
  --matrix MATRIX       Custom 4x4 transformation matrix (16 space-separated values).
  --verbose             Print interpreted matrix plus some test values to check

Example output focusing on Sand:

./draw_all.sh --filename ../nd_hall_with_lar_tms_sand.gdml --axis

Screenshot 2025-02-27 020327
Screenshot 2025-02-27 015539

@jdkio jdkio added the enhancement New feature or request label Feb 27, 2025
@jdkio jdkio requested a review from ast0815 February 27, 2025 07:10
Copy link
Member

@ast0815 ast0815 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks super useful. I will have a look about integrating it into the CI workflows after it is merged. Only nitpick is the lot of empty lines at the end of the file. :)

Suggestion: Format the whole file with black or ruff.

@ast0815
Copy link
Member

ast0815 commented Feb 28, 2025

Is this ready for merge now? Or do you still need to work on it for a bit?

@ast0815
Copy link
Member

ast0815 commented Mar 4, 2025

Bump @jdkio

@jdkio
Copy link
Contributor Author

jdkio commented Mar 12, 2025

@ast0815, it says you requested changes but I don't see any. Do you have to re-review?

@ast0815
Copy link
Member

ast0815 commented Mar 13, 2025

Those were the changes I originally requested. Now my only question is whether or not you are done. 😄
Since you have added more functionality since my review. If you are happy to merge, I will merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants