Metadata-Version: 2.1
Name: geviewer
Version: 0.0.8
Summary: A lightweight, Python-based visualization tool for Geant4.
Home-page: https://github.com/clarkehardy/geviewer.git
Author: Clarke Hardy
Author-email: Clarke Hardy <cahardy@stanford.edu>
License: MIT License
        
        Copyright (c) 2024 Clarke Hardy
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: repository, https://github.com/clarkehardy/geviewer.git
Keywords: geant4,viewer,visualizer,display,event,simulation,hep,physics,particle,track,detector,geometry,vrml
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: pyvista
Requires-Dist: tqdm

# GeViewer
![PyPI - Version](https://img.shields.io/pypi/v/geviewer)
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/clarkehardy/geviewer/.github%2Fworkflows%2Fpython-package.yml)
![Last Commit](https://img.shields.io/github/last-commit/clarkehardy/geviewer)
![GitHub License](https://img.shields.io/github/license/clarkehardy/geviewer)

A lightweight, Python-based visualization tool for Geant4. GeViewer provides a convenient way to view detector geometries, particle trajectories, and hits, with smooth rendering in an interactive window.

## Getting started
### Dependencies
The following packages are required:
* `numpy`
* `tqdm`
* `pyvista`

### Installation
GeViewer can be installed using `pip` as follows:
```bash
pip install geviewer
```
To uninstall:
```bash
pip uninstall geviewer
```

## Usage
This package is intended to be used primarily as a command line tool. Following installation, the program can be run using:
```bash
geviewer /path/to/file.wrl
```
This will load the meshes described in `/path/to/file.wrl` and display them in an interactive window. The viewing perspective can be changed by clicking, dragging, and scrolling in the window, while other options can be toggled on and off using key presses. More specific instructions for use will print in the terminal window when the program is launched.

###  Instructions for Geant4
To produce Geant4 outputs that can be read by GeViewer, you must use `/vis/open VRML2FILE` to tell Geant4 to save the visualization as a VRML file. The following sample macro shows how this could be implemented.
```
# tell Geant4 we want a VRML file rather than to use an interactive viewer
/vis/open VRML2FILE

# the main content of your Geant4 macro goes here

# if you want to see particle tracks and hits
/run/beamOn 1

# by default, the file will be saved as g4_00.wrl
# but it can easily be renamed from within the macro
/control/shell mv g4_00.wrl /new/path/to/file.wrl

# the output can be piped directly to geviewer
/control/shell geviewer /new/path/to/file.wrl

exit
```
Note that if you are running Geant4 on a remote machine over `ssh`, piping the simulation outputs directly to GeViewer may not work as expected. If this is the case, you can download the VRML files and run GeViewer on your local machine instead.


### Safe mode
By default, GeViewer relies on its own VRML parser to extract the meshes to be plotted, however this has only been tested on a small sample set of Geant4 simulation results. If you encounter file parsing errors, try using the `--safe-mode` command line argument (and let me know what caused the error so I can update the parser). This will use a VRML parsing tool from [`vtk`](https://vtk.org) which should be more robust, but which does not allow the program to distinguish trajectories, hits, and detector geometry. In this mode, some features will not be available.

## License
Distributed under the MIT License. See [LICENSE](LICENSE) for more information.

## Contact
Clarke Hardy - [cahardy@stanford.edu](mailto:cahardy@stanford.edu)
