Skip to content
A CAD file interface for GEANT4
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmake/Modules Added a cmake module to find tetgen (from here: https://raw.githubuse… Aug 13, 2017
examples No need to cast the filename from a string to a char array. Oct 9, 2017
external Updated assimp to version 4+. Sep 20, 2017
include Specifying entires for the Unknown file type enumin the extension, st… Nov 8, 2017
.gitignore Ignoring vim *.swp files. Nov 19, 2014
CMakeLists.txt Added a config header for specifying the default reader to use at com… Nov 1, 2017
LICENSE Added a license file. Dec 11, 2014
Poole et al. - A CAD interface for GEANT4.pdf
Poole et al. - Fast tessellated solid navigation in GEANT4.pdf Added example usage of new v2 api. Aug 13, 2017
screenshot.png added screenshot Feb 19, 2013


This master branch is where development occurs. Make sure you checkout v1.1 if your are trying to compile the latest release, or download it from here.

CADMesh version 2.0 is under development right now, with a new API that is much easier to use:

    auto mesh = CADMesh::TessellatedMesh::FromPLY("mesh.ply");
    G4VSolid* solid = mesh->GetSolid();


Importing predefined CAD models into GEANT4 is not always possible or requires intermediate file format conversion to Geometry Description Markup Language (GDML) using commercial or third party software. CADMesh is a direct CAD model import interface for GEANT4 leveraging ASSIMP for reading the CAD files. Currently it supports the import of triangular facet surface meshes defined in formats such as STL and PLY. A G4TessellatedSolid is returned and can be included in a standard user detector constructor. You can find the project page and a git repository here. The old Google Code page for CADMesh redirects to this page.

Screen Shot

Additional functionality is included for the fast navigation of tessellated solids by automatically creating equivalent tetrahedral meshes thereby making smart voxelisation available for the solid.

Citing CADMesh

CADMesh is described in a technical paper, available here, and in this repository. If you would like the cite the article, you may wish use the following bibtex entry:

    author = {Poole, C. M. and Cornelius, I. and Trapp, J. V. and Langton, C. M.},
    title = {{A CAD Interface for GEANT4}},
    journal={Australasian Physical & Engineering Science in Medicine},
    year = 2012,
    month = September,
    doi = {10.1007/s13246-012-0159-8},
    url = {}

The fast tessellated solid navigation technique included in CADMesh is described here, the paper is included in this repository as well:

    title={Fast Tessellated Solid Navigation in GEANT4},
    author={Poole, C. and Cornelius, I. and Trapp, J. and Langton, C.M.},
    journal={IEEE Transactions on Nuclear Science},
    publisher={Institute of Electrical and Electronics Engineers}

Example Usage

The following shows basic default usage for cadmesh in a UserDetectorConstruction:

// User Detector Constructor
#include "CADMesh.hh"
G4ThreeVector offset;
G4VSolid * cad_solid;
G4LogicalVolume * cad_logical;
G4VPhysicalVolume * cad_physical;
offset = G4ThreeVector(-30*cm, 0, 0);
CADMesh * mesh = new CADMesh("../../models/cone.ply", mm, offset, false);

cad_solid = mesh->TessellatedMesh();
cad_logical = new G4LogicalVolume(cad_solid, water, "cad_logical", 0, 0, 0);
cad_physical = new G4PVPlacement(0, G4ThreeVector(), cad_logical,
                                     "cad_physical", world_logical, false, 0);

# CMakeLists.txt
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)

# GEANT4 core
find_package(Geant4 REQUIRED ui_all vis_all)

# CADMesh

# User code
file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)

add_executable(cadmesh_example ${sources} ${headers})
target_link_libraries(cadmesh_example ${Geant4_LIBRARIES})
target_link_libraries(cadmesh_example ${cadmesh_LIBRARIES})


A working installation of the following libraries or packages is required:

They are included in the repository as external projects/submodules.


Download the latest release of CADMesh from the Downloads section, and extract the archive, or checkout the development branch from the repository.

# CADMesh latest release
git clone
git checkout v1.1

# OR download a release from, and extract the download somewhere.

cd cadmesh/

# Fetch the external dependancies (optional), running
# cmake will result in this happening anyway.
# git submodule update --init --recursive

mkdir build
cd build

cmake .. -DCMAKE_INSTALL_PREFIX:PATH=<optional install location>
sudo make install

Here is a basic example usage. The CMakeLists.txt file illustrates how to link against CADMesh (which requires CADMesh to be installed somewhere).

# Run example (Linux with g++)
cd examples/basic
mkdir build
cd build

cmake .. -Dcadmesh_DIR:PATH=<cadmesh install location> 

./cadmesh_example <macro> <cad file name> <cad file type, optional>

# Still in the build directory:
./cadmesh_example ../macros/vis.mac ../../../models/cone.ply
Idle> exit

# To use the tetrahedram meshing as well (tetgen needs to know the file type):
./cadmesh_example ../macros/vis.mac ../../../models/cone.ply PLY

If you get an error such as this:

./build/cadmesh_example: error while loading shared libraries: cannot open shared object file: No such file or directory

Make sure the CADMesh library is in your path:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<cadmesh install location>/lib

or on a Mac:

export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:<cadmesh install location>/lib
You can’t perform that action at this time.