diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..3f69839 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,45 @@ +language: cpp +os: linux +dist: bionic +sudo: required + +addons: + apt: + sources: + - sourceline: "ppa:ubuntu-toolchain-r/test" + update: true + packages: + - libxerces-c3.2 + - libxerces-c-dev + - expat + - libexpat1-dev + - assimp-utils + - libassimp-dev + - libassimp-doc + - libassimp4 + - libtet1.5 + - libtet1.5-dev + - tetgen + - gcc-9 + - g++-9 + #- geant4 + +before_install: + - CC=gcc-9 && CXX=g++-9 + +install: + - cd ${TRAVIS_BUILD_DIR}/.. + - wget https://www.ikp.uni-koeln.de/~jmayer/github/geant4_10.5.1_amd64.deb + - sudo dpkg -i geant4_10.5.1_amd64.deb + - source /usr/bin/geant4.sh + - git clone -b v1.1 https://github.com/christopherpoole/CADMesh.git ${TRAVIS_BUILD_DIR}/../CADMesh-src + - cd ${TRAVIS_BUILD_DIR}/../CADMesh-src + - mkdir build && cd build + - cmake .. -DWITH_SYS_ASSIMP=ON -DWITH_SYS_TETGEN=ON + - make -j8 + - sudo make install + - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/ + +script: + - cd $TRAVIS_BUILD_DIR + - ./G4Batch.sh diff --git a/G4Batch.sh b/G4Batch.sh index 25de92a..46f0e87 100755 --- a/G4Batch.sh +++ b/G4Batch.sh @@ -19,8 +19,11 @@ cd .. ## Set CAD Directory -export G4HORUS_CAD_DIR=`pwd`/cad - +if [ -z "${G4HORUS_CAD_DIR}" ] +then + export G4HORUS_CAD_DIR=`pwd`/cad +fi +echo "CAD Dir: ${G4HORUS_CAD_DIR}" ## Create output dir and run full simulation mkdir -p out diff --git a/readme.md b/readme.md index a96881e..a6c8485 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,7 @@ # G4Horus +[![Build Status](https://travis-ci.org/janmayer/G4Horus.svg?branch=master)](https://travis-ci.org/janmayer/G4Horus) + An implementation of the HORUS High-Purity Germanium (HPGe) γ-ray spectrometer and associated equipment in Geant4. ![G4Horus Default Geometry](doc/g4horus.png) diff --git a/src/geometries/CADElement.cc b/src/geometries/CADElement.cc index 3628213..83fa4b3 100644 --- a/src/geometries/CADElement.cc +++ b/src/geometries/CADElement.cc @@ -6,8 +6,10 @@ CADElement::CADElement(std::string filename, const std::string& material, const : fFilename(std::move(filename)) , fLV(nullptr) { - std::cout << "CADElement: Meshing " << GetCadFile(fFilename) << std::endl; - auto mesh = CADMesh(GetCadFile(fFilename)); + const auto file = GetCadFile(fFilename); + std::cout << "CADElement: Meshing " << fFilename << "(" << file << ") ..." << std::endl; + // This Version of Cadmesh wants and non-const char ... + auto mesh = CADMesh(const_cast(file.c_str())); mesh.SetScale(mm); fLV = new G4LogicalVolume(mesh.TessellatedMesh(), G4Material::GetMaterial(material), fFilename + "_lV"); auto va = G4VisAttributes(color); @@ -21,7 +23,7 @@ void CADElement::Place(G4LogicalVolume* worldLV, G4RotationMatrix* rot, const G4 new G4PVPlacement(rot, trans, fLV, fFilename + "_pV", worldLV, false, 0, checkOverlaps); } -char* CADElement::GetCadFile(const std::string& filename) const +std::string CADElement::GetCadFile(const std::string& filename) const { std::string loc; const char* path = std::getenv("G4HORUS_CAD_DIR"); @@ -30,6 +32,5 @@ char* CADElement::GetCadFile(const std::string& filename) const } else { loc = std::string(path) + "/" + filename + ".stl"; } - // This Version of Cadmesh wants and non-const char ... - return const_cast(loc.c_str()); + return loc; } diff --git a/src/geometries/CADElement.hh b/src/geometries/CADElement.hh index 86a2c1e..3e268a6 100644 --- a/src/geometries/CADElement.hh +++ b/src/geometries/CADElement.hh @@ -13,7 +13,7 @@ class CADElement { }; private: - char* GetCadFile(const std::string& filename) const; + std::string GetCadFile(const std::string& filename) const; const std::string fFilename; G4LogicalVolume* fLV;