Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/linux-eic-shell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ jobs:
run: |
CXX="${{ matrix.CXX }}" cmake -B build -S . \
-DCMAKE_BUILD_TYPE=${{ matrix.CMAKE_BUILD_TYPE }} \
-DUSE_GEOCAD=ON \
-DCMAKE_INSTALL_PREFIX=install
cmake --build build -j $(getconf _NPROCESSORS_ONLN)
ctest --test-dir build --output-on-failure --no-tests=error -j $(getconf _NPROCESSORS_ONLN)
cmake --build build -j $(getconf _NPROCESSORS_ONLN) --target install
- name: Compress install directory
run: tar -caf install.tar.zst install/
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ endif()

# Use GNU install dirs
include(GNUInstallDirs)
include(CTest)

# Build type
if (NOT CMAKE_BUILD_TYPE)
Expand Down
4 changes: 4 additions & 0 deletions src/geocad/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,7 @@ install(TARGETS GeoCad
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)

if(BUILD_TESTING)
add_subdirectory(tests)
endif()
16 changes: 16 additions & 0 deletions src/geocad/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
set(geocad_unit_test npdet_geocad_unit_partial_tree)
add_executable(${geocad_unit_test} unit_partial_tree.cxx)
target_link_libraries(${geocad_unit_test}
PRIVATE GeoCad ROOT::Geom
)
add_test(NAME ${geocad_unit_test} COMMAND ${geocad_unit_test})

set(geocad_integration_test npdet_geocad_integration_create_step)
add_executable(${geocad_integration_test} integration_create_step.cxx)
target_link_libraries(${geocad_integration_test}
PRIVATE GeoCad ROOT::Geom
)
add_test(
NAME ${geocad_integration_test}
COMMAND ${geocad_integration_test} ${CMAKE_CURRENT_BINARY_DIR}/npdet_geocad_test_geometry.stp
)
46 changes: 46 additions & 0 deletions src/geocad/tests/integration_create_step.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include <filesystem>
#include <iostream>
#include <string>

#include "TGeoManager.h"
#include "TGeoMaterial.h"
#include "TGeoMedium.h"
#include "TGeoToStep.h"
#include "TGeoVolume.h"

namespace fs = std::filesystem;

namespace {
TGeoManager* make_test_geometry() {
auto* geom = new TGeoManager("npdet_geo_test", "npdet geocad integration test");
auto* mat = new TGeoMaterial("Vacuum", 0, 0, 0);
auto* med = new TGeoMedium("Vacuum", 1, mat);

auto* top = geom->MakeBox("top", med, 100., 100., 100.);
auto* child = geom->MakeBox("child", med, 10., 10., 10.);
top->AddNode(child, 1);
geom->SetTopVolume(top);
geom->CloseGeometry();
return geom;
}
} // namespace

int main(int argc, char* argv[]) {
if (argc != 2) {
std::cerr << "Expected output path argument\n";
return 1;
}

const fs::path out_path = argv[1];
fs::remove(out_path);

TGeoToStep converter(make_test_geometry());
converter.CreateGeometry(out_path.string().c_str(), 2, 1.0);

if (!fs::exists(out_path) || fs::file_size(out_path) == 0) {
std::cerr << "STEP output file was not created\n";
return 1;
}

return 0;
}
41 changes: 41 additions & 0 deletions src/geocad/tests/unit_partial_tree.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include <iostream>

#include "src/TOCCToStep.h"
#include "TGeoManager.h"
#include "TGeoMaterial.h"
#include "TGeoMedium.h"
#include "TGeoVolume.h"

namespace {
TGeoManager* make_test_geometry() {
auto* geom = new TGeoManager("npdet_geo_test", "npdet geocad unit test");
auto* mat = new TGeoMaterial("Vacuum", 0, 0, 0);
auto* med = new TGeoMedium("Vacuum", 1, mat);

auto* top = geom->MakeBox("top", med, 100., 100., 100.);
auto* child = geom->MakeBox("child", med, 10., 10., 10.);
top->AddNode(child, 1);
geom->SetTopVolume(top);
geom->CloseGeometry();
return geom;
}
} // namespace

int main() {
auto* geom = make_test_geometry();

TOCCToStep converter;
converter.OCCShapeCreation(geom, 1.0);

const bool found_child = converter.OCCPartialTreeCreation(geom, "child", 2);
const bool found_fake = converter.OCCPartialTreeCreation(geom, "does_not_exist", 2);

delete geom;

if (!found_child || found_fake) {
std::cerr << "Unexpected partial tree lookup results\n";
return 1;
}

return 0;
}
6 changes: 5 additions & 1 deletion src/tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ install(TARGETS ${exe_name}
# npdet_to_step needs the (formerly part of ROOT) GeoCad library
if(TARGET GeoCad)
set(exe_name npdet_to_step)
add_executable(${exe_name} src/${exe_name}.cxx src/settings.cxx)
add_executable(${exe_name} src/${exe_name}.cxx src/settings.cxx src/npdet_to_step_cli.cxx)
target_include_directories(${exe_name}
PRIVATE include )
target_compile_features(${exe_name}
Expand Down Expand Up @@ -98,6 +98,10 @@ install(TARGETS ${exe_name}
EXPORT NPDetTargets
RUNTIME DESTINATION bin )

if(BUILD_TESTING)
add_subdirectory(tests)
endif()

# ------------------------------------
# dd_web_display
# ------------------------------------
Expand Down
Loading