Skip to content

Commit

Permalink
shell: change argument checks, test them
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgessinger committed Aug 27, 2024
1 parent 67ab356 commit bdb596b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
11 changes: 5 additions & 6 deletions Core/src/Geometry/PortalShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@

#include <algorithm>
#include <numeric>
#include <ranges>

namespace Acts {

SingleCylinderPortalShell::SingleCylinderPortalShell(
const GeometryContext& gctx, TrackingVolume& volume) {
assert(volume.volumeBounds().type() == VolumeBounds::BoundsType::eCylinder);
SingleCylinderPortalShell::SingleCylinderPortalShell(TrackingVolume& volume) {
if (volume.volumeBounds().type() != VolumeBounds::BoundsType::eCylinder) {
throw std::invalid_argument("Invalid volume bounds type");
}

const auto& bounds =
dynamic_cast<const CylinderVolumeBounds&>(volume.volumeBounds());

Expand Down Expand Up @@ -164,8 +165,6 @@ CylinderStackPortalShell::CylinderStackPortalShell(
} else {
throw std::invalid_argument("Invalid direction");
}

// @TODO: Handle portal fusing
}

std::size_t CylinderStackPortalShell::size() const {
Expand Down
8 changes: 8 additions & 0 deletions Tests/UnitTests/Core/Geometry/PortalShellTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <boost/test/unit_test_suite.hpp>

#include "Acts/Definitions/Units.hpp"
#include "Acts/Geometry/CuboidVolumeBounds.hpp"
#include "Acts/Geometry/CylinderVolumeBounds.hpp"
#include "Acts/Geometry/GridPortalLink.hpp"
#include "Acts/Geometry/Portal.hpp"
Expand Down Expand Up @@ -48,6 +49,13 @@ BOOST_AUTO_TEST_CASE(ConstructionFromVolume) {
auto cyl3 = makeVolume(30_mm, 40_mm, 100_mm, 45_degree);
auto cyl4 = makeVolume(0_mm, 40_mm, 100_mm, 45_degree);

TrackingVolume boxVolume(
Transform3::Identity(),
std::make_shared<CuboidVolumeBounds>(10_mm, 10_mm, 10_mm));

BOOST_CHECK_THROW(SingleCylinderPortalShell{boxVolume},
std::invalid_argument);

SingleCylinderPortalShell shell1{cyl1};
BOOST_CHECK_EQUAL(shell1.size(), 4);

Expand Down

0 comments on commit bdb596b

Please sign in to comment.