diff --git a/Core/include/Acts/Navigation/NavigationStateUpdaters.hpp b/Core/include/Acts/Navigation/NavigationStateUpdaters.hpp index d1eed8b948b..8bd00d6a406 100644 --- a/Core/include/Acts/Navigation/NavigationStateUpdaters.hpp +++ b/Core/include/Acts/Navigation/NavigationStateUpdaters.hpp @@ -56,7 +56,7 @@ inline void updateCandidates(const GeometryContext& gctx, gctx, position, direction, c.boundaryTolerance, s_onSurfaceTolerance); for (auto& si : sIntersection.split()) { c.objectIntersection = si; - if (c.objectIntersection && + if (c.objectIntersection.isValid() && c.objectIntersection.pathLength() > overstepTolerance) { nextSurfaceCandidates.emplace_back(c); } diff --git a/Core/include/Acts/Propagator/DirectNavigator.hpp b/Core/include/Acts/Propagator/DirectNavigator.hpp index 20f15ad8221..98c63bd659c 100644 --- a/Core/include/Acts/Propagator/DirectNavigator.hpp +++ b/Core/include/Acts/Propagator/DirectNavigator.hpp @@ -277,8 +277,8 @@ class DirectNavigator { boundaryTolerance, tolerance); for (auto& intersection : intersections.split()) { - if (detail::checkIntersection(intersection, nearLimit, farLimit, - logger())) { + if (detail::checkPathLength(intersection.pathLength(), nearLimit, + farLimit, logger())) { return intersection; } } diff --git a/Core/include/Acts/Propagator/Navigator.hpp b/Core/include/Acts/Propagator/Navigator.hpp index ab390fa4cb1..9d8efc93428 100644 --- a/Core/include/Acts/Propagator/Navigator.hpp +++ b/Core/include/Acts/Propagator/Navigator.hpp @@ -989,7 +989,7 @@ class Navigator { state.options.direction * stepper.direction(state.stepping), BoundaryTolerance::Infinite(), state.options.surfaceTolerance) .closest(); - if (targetIntersection) { + if (targetIntersection.isValid()) { ACTS_VERBOSE(volInfo(state) << "Target estimate position (" << targetIntersection.position().x() << ", " diff --git a/Core/include/Acts/Propagator/StandardAborters.hpp b/Core/include/Acts/Propagator/StandardAborters.hpp index 144edfda1df..23c045eac7e 100644 --- a/Core/include/Acts/Propagator/StandardAborters.hpp +++ b/Core/include/Acts/Propagator/StandardAborters.hpp @@ -130,9 +130,9 @@ struct SurfaceReached { bool intersectionFound = false; for (const auto& intersection : sIntersection.split()) { - if (intersection && - detail::checkIntersection(intersection.intersection(), nearLimit, - farLimit, logger)) { + if (intersection.isValid() && + detail::checkPathLength(intersection.pathLength(), nearLimit, + farLimit, logger)) { stepper.updateStepSize(state.stepping, intersection.pathLength(), ConstrainedStep::aborter, false); ACTS_VERBOSE( diff --git a/Core/include/Acts/Propagator/TryAllNavigator.hpp b/Core/include/Acts/Propagator/TryAllNavigator.hpp index 3addabaebd9..a516a3292d2 100644 --- a/Core/include/Acts/Propagator/TryAllNavigator.hpp +++ b/Core/include/Acts/Propagator/TryAllNavigator.hpp @@ -343,8 +343,9 @@ class TryAllNavigator : public TryAllNavigatorBase { state.options.surfaceTolerance); for (const auto& intersection : intersections.first.split()) { // exclude invalid intersections - if (!intersection || - !detail::checkIntersection(intersection, nearLimit, farLimit)) { + if (!intersection.isValid() || + !detail::checkPathLength(intersection.pathLength(), nearLimit, + farLimit)) { continue; } // store candidate @@ -746,8 +747,9 @@ class TryAllOverstepNavigator : public TryAllNavigatorBase { state.geoContext, end, direction, state.options.surfaceTolerance); for (const auto& intersection : intersections.first.split()) { // exclude invalid intersections - if (!intersection || - !detail::checkIntersection(intersection, nearLimit, farLimit)) { + if (!intersection.isValid() || + !detail::checkPathLength(intersection.pathLength(), nearLimit, + farLimit)) { continue; } // exclude last candidate diff --git a/Core/include/Acts/Propagator/detail/SteppingHelper.hpp b/Core/include/Acts/Propagator/detail/SteppingHelper.hpp index 1ccd139fdb3..01db7f6c8fd 100644 --- a/Core/include/Acts/Propagator/detail/SteppingHelper.hpp +++ b/Core/include/Acts/Propagator/detail/SteppingHelper.hpp @@ -56,8 +56,9 @@ Acts::Intersection3D::Status updateSingleSurfaceStatus( const double nearLimit = std::numeric_limits::lowest(); const double farLimit = state.stepSize.value(ConstrainedStep::aborter); - if (sIntersection && detail::checkIntersection(sIntersection.intersection(), - nearLimit, farLimit, logger)) { + if (sIntersection.isValid() && + detail::checkPathLength(sIntersection.pathLength(), nearLimit, farLimit, + logger)) { ACTS_VERBOSE("Surface is reachable"); stepper.updateStepSize(state, sIntersection.pathLength(), ConstrainedStep::actor); diff --git a/Core/include/Acts/Utilities/Intersection.hpp b/Core/include/Acts/Utilities/Intersection.hpp index f30da706c07..49dc23517b7 100644 --- a/Core/include/Acts/Utilities/Intersection.hpp +++ b/Core/include/Acts/Utilities/Intersection.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2016-2023 CERN for the benefit of the Acts project +// Copyright (C) 2016-2024 CERN for the benefit of the Acts project // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -60,10 +60,15 @@ class Intersection { : m_position(position), m_pathLength(pathLength), m_status(status) {} /// Returns whether the intersection was successful or not - constexpr explicit operator bool() const { - return m_status != Status::missed; + /// @deprecated + [[deprecated("Use isValid() instead")]] constexpr explicit operator bool() + const { + return isValid(); } + /// Returns whether the intersection was successful or not + constexpr bool isValid() const { return m_status != Status::missed; } + constexpr const Position& position() const { return m_position; } constexpr ActsScalar pathLength() const { return m_pathLength; } @@ -141,10 +146,15 @@ class ObjectIntersection { : m_intersection(intersection), m_object(object), m_index(index) {} /// Returns whether the intersection was successful or not - constexpr explicit operator bool() const { - return m_intersection.operator bool(); + /// @deprecated + [[deprecated("Use isValid() instead")]] constexpr explicit operator bool() + const { + return isValid(); } + /// Returns whether the intersection was successful or not + constexpr bool isValid() const { return m_intersection.isValid(); } + constexpr const Intersection3D& intersection() const { return m_intersection; } @@ -256,50 +266,16 @@ class ObjectMultiIntersection { namespace detail { -/// This function checks if an intersection is valid for the specified -/// path-limit and overstep-limit -/// -/// @tparam intersection_t Type of the intersection object +/// This function checks if an intersection path length is valid for the +/// specified near-limit and far-limit /// -/// @param intersection The intersection to check -/// @param nearLimit The minimum distance for an intersection to be considered -/// @param farLimit The maximum distance for an intersection to be considered +/// @param pathLength The path length of the intersection +/// @param nearLimit The minimum path length for an intersection to be considered +/// @param farLimit The maximum path length for an intersection to be considered /// @param logger A optionally supplied logger which prints out a lot of infos /// at VERBOSE level -template -bool checkIntersection(const intersection_t& intersection, double nearLimit, - double farLimit, - const Logger& logger = getDummyLogger()) { - const double distance = intersection.pathLength(); - // TODO why? - const double tolerance = s_onSurfaceTolerance; - - ACTS_VERBOSE(" -> near limit, far limit, distance: " - << nearLimit << ", " << farLimit << ", " << distance); - - const bool coCriterion = distance > nearLimit; - const bool cpCriterion = distance < farLimit + tolerance; - - const bool accept = coCriterion && cpCriterion; - - if (accept) { - ACTS_VERBOSE("Intersection is WITHIN limit"); - } else { - ACTS_VERBOSE("Intersection is OUTSIDE limit because: "); - if (!coCriterion) { - ACTS_VERBOSE("- intersection path length " - << distance << " <= near limit " << nearLimit); - } - if (!cpCriterion) { - ACTS_VERBOSE("- intersection path length " - << distance << " is over the far limit " - << (farLimit + tolerance) << " (including tolerance of " - << tolerance << ")"); - } - } - - return accept; -} +bool checkPathLength(double pathLength, double nearLimit, double farLimit, + const Logger& logger = getDummyLogger()); } // namespace detail diff --git a/Core/include/Acts/Utilities/TrackHelpers.hpp b/Core/include/Acts/Utilities/TrackHelpers.hpp index 295812dd2d3..f9883bfeb63 100644 --- a/Core/include/Acts/Utilities/TrackHelpers.hpp +++ b/Core/include/Acts/Utilities/TrackHelpers.hpp @@ -195,7 +195,7 @@ findTrackStateForExtrapolation( } SurfaceIntersection intersection = intersect(*first); - if (!intersection) { + if (!intersection.isValid()) { ACTS_ERROR("no intersection found"); return Result>::failure( TrackExtrapolationError::ReferenceSurfaceUnreachable); @@ -215,7 +215,7 @@ findTrackStateForExtrapolation( } SurfaceIntersection intersection = intersect(*last); - if (!intersection) { + if (!intersection.isValid()) { ACTS_ERROR("no intersection found"); return Result>::failure( TrackExtrapolationError::ReferenceSurfaceUnreachable); @@ -246,13 +246,13 @@ findTrackStateForExtrapolation( double absDistanceFirst = std::abs(intersectionFirst.pathLength()); double absDistanceLast = std::abs(intersectionLast.pathLength()); - if (intersectionFirst && absDistanceFirst <= absDistanceLast) { + if (intersectionFirst.isValid() && absDistanceFirst <= absDistanceLast) { ACTS_VERBOSE("using first track state with intersection at " << intersectionFirst.pathLength()); return std::make_pair(*first, intersectionFirst.pathLength()); } - if (intersectionLast && absDistanceLast <= absDistanceFirst) { + if (intersectionLast.isValid() && absDistanceLast <= absDistanceFirst) { ACTS_VERBOSE("using last track state with intersection at " << intersectionLast.pathLength()); return std::make_pair(*last, intersectionLast.pathLength()); diff --git a/Core/src/Geometry/GenericApproachDescriptor.cpp b/Core/src/Geometry/GenericApproachDescriptor.cpp index cc1320f19e1..e532e2f5eb2 100644 --- a/Core/src/Geometry/GenericApproachDescriptor.cpp +++ b/Core/src/Geometry/GenericApproachDescriptor.cpp @@ -35,8 +35,9 @@ Acts::SurfaceIntersection Acts::GenericApproachDescriptor::approachSurface( auto sfIntersection = sf->intersect(gctx, position, direction, boundaryTolerance); for (const auto& intersection : sfIntersection.split()) { - if (intersection && - detail::checkIntersection(intersection, nearLimit, farLimit)) { + if (intersection.isValid() && + detail::checkPathLength(intersection.pathLength(), nearLimit, + farLimit)) { sIntersections.push_back(intersection); } } diff --git a/Core/src/Geometry/Layer.cpp b/Core/src/Geometry/Layer.cpp index 0f1dee70659..c88bfccb301 100644 --- a/Core/src/Geometry/Layer.cpp +++ b/Core/src/Geometry/Layer.cpp @@ -14,6 +14,7 @@ #include "Acts/Propagator/Navigator.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/Surface.hpp" +#include "Acts/Utilities/Intersection.hpp" #include #include @@ -138,7 +139,7 @@ Acts::Layer::compatibleSurfaces( // indicates wrong direction or faulty setup // -> do not return compatible surfaces since they may lead you on a wrong // navigation path - if (endInter) { + if (endInter.isValid()) { farLimit = endInter.pathLength(); } else { return sIntersections; @@ -196,8 +197,8 @@ Acts::Layer::compatibleSurfaces( // the surface intersection SurfaceIntersection sfi = sf.intersect(gctx, position, direction, boundaryTolerance).closest(); - if (sfi && - detail::checkIntersection(sfi.intersection(), nearLimit, farLimit) && + if (sfi.isValid() && + detail::checkPathLength(sfi.pathLength(), nearLimit, farLimit) && isUnique(sfi)) { sIntersections.push_back(sfi); } @@ -267,8 +268,8 @@ Acts::SurfaceIntersection Acts::Layer::surfaceOnApproach( auto findValidIntersection = [&](const SurfaceMultiIntersection& sfmi) -> SurfaceIntersection { for (const auto& sfi : sfmi.split()) { - if (sfi && - detail::checkIntersection(sfi.intersection(), nearLimit, farLimit)) { + if (sfi.isValid() && + detail::checkPathLength(sfi.pathLength(), nearLimit, farLimit)) { return sfi; } } diff --git a/Core/src/Geometry/TrackingVolume.cpp b/Core/src/Geometry/TrackingVolume.cpp index 8b34abf912e..9cc4afc2a37 100644 --- a/Core/src/Geometry/TrackingVolume.cpp +++ b/Core/src/Geometry/TrackingVolume.cpp @@ -19,6 +19,7 @@ #include "Acts/Surfaces/RegularSurface.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/BinningType.hpp" +#include "Acts/Utilities/Intersection.hpp" #include #include @@ -440,7 +441,7 @@ TrackingVolume::compatibleBoundaries(const GeometryContext& gctx, [&](SurfaceMultiIntersection& candidates, const BoundarySurface* boundary) -> BoundaryIntersection { for (const auto& intersection : candidates.split()) { - if (!intersection) { + if (!intersection.isValid()) { continue; } @@ -464,8 +465,8 @@ TrackingVolume::compatibleBoundaries(const GeometryContext& gctx, ACTS_VERBOSE("Check intersection with surface " << boundary->surfaceRepresentation().geometryId()); - if (detail::checkIntersection(intersection.intersection(), nearLimit, - farLimit, logger)) { + if (detail::checkPathLength(intersection.pathLength(), nearLimit, + farLimit, logger)) { return BoundaryIntersection(intersection, boundary); } } @@ -495,7 +496,7 @@ TrackingVolume::compatibleBoundaries(const GeometryContext& gctx, options.boundaryTolerance); // Intersect and continue auto intersection = checkIntersection(candidates, boundary.get()); - if (intersection.first) { + if (intersection.first.isValid()) { ACTS_VERBOSE(" - Proceed with surface"); intersections.push_back(intersection); } else { @@ -550,7 +551,7 @@ TrackingVolume::compatibleLayers( auto atIntersection = tLayer->surfaceOnApproach(gctx, position, direction, options); // Intersection is ok - take it (move to surface on approach) - if (atIntersection) { + if (atIntersection.isValid()) { // create a layer intersection lIntersections.push_back(LayerIntersection(atIntersection, tLayer)); } diff --git a/Core/src/Utilities/CMakeLists.txt b/Core/src/Utilities/CMakeLists.txt index 64ede8dcd89..17d0492d51e 100644 --- a/Core/src/Utilities/CMakeLists.txt +++ b/Core/src/Utilities/CMakeLists.txt @@ -7,4 +7,5 @@ target_sources( SpacePointUtility.cpp TrackHelpers.cpp BinningType.cpp + Intersection.cpp ) diff --git a/Core/src/Utilities/Intersection.cpp b/Core/src/Utilities/Intersection.cpp new file mode 100644 index 00000000000..2c9531bdfdf --- /dev/null +++ b/Core/src/Utilities/Intersection.cpp @@ -0,0 +1,45 @@ +// This file is part of the Acts project. +// +// Copyright (C) 2024 CERN for the benefit of the Acts project +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include "Acts/Utilities/Intersection.hpp" + +namespace Acts { + +bool detail::checkPathLength(double pathLength, double nearLimit, + double farLimit, const Logger& logger) { + // TODO why? + const double tolerance = s_onSurfaceTolerance; + + ACTS_VERBOSE(" -> near limit, far limit, distance: " + << nearLimit << ", " << farLimit << ", " << pathLength); + + const bool coCriterion = pathLength > nearLimit; + const bool cpCriterion = pathLength < farLimit + tolerance; + + const bool accept = coCriterion && cpCriterion; + + if (accept) { + ACTS_VERBOSE("Intersection is WITHIN limit"); + } else { + ACTS_VERBOSE("Intersection is OUTSIDE limit because: "); + if (!coCriterion) { + ACTS_VERBOSE("- intersection path length " + << pathLength << " <= near limit " << nearLimit); + } + if (!cpCriterion) { + ACTS_VERBOSE("- intersection path length " + << pathLength << " is over the far limit " + << (farLimit + tolerance) << " (including tolerance of " + << tolerance << ")"); + } + } + + return accept; +} + +} // namespace Acts diff --git a/Fatras/src/Digitization/PlanarSurfaceMask.cpp b/Fatras/src/Digitization/PlanarSurfaceMask.cpp index badf058c611..f660082bfad 100644 --- a/Fatras/src/Digitization/PlanarSurfaceMask.cpp +++ b/Fatras/src/Digitization/PlanarSurfaceMask.cpp @@ -38,7 +38,7 @@ namespace { /// @param sLength The segment length, maximal allowed length void checkIntersection(std::vector& intersections, const Acts::Intersection2D& candidate, double sLength) { - if (candidate && candidate.pathLength() > 0 && + if (candidate.isValid() && candidate.pathLength() > 0 && candidate.pathLength() < sLength) { intersections.push_back(candidate); } @@ -282,7 +282,7 @@ ActsFatras::PlanarSurfaceMask::annulusMask(const Acts::AnnulusBounds& aBounds, Acts::VectorHelpers::phi(vertices[phii[iarc * 2]] - moduleOrigin), Acts::VectorHelpers::phi(vertices[phii[iarc * 2 + 1]] - moduleOrigin), segment[0] - moduleOrigin, sDir); - if (intersection) { + if (intersection.isValid()) { checkIntersection(intersections, Acts::Intersection2D( intersection.position() + moduleOrigin, diff --git a/Tests/UnitTests/Core/Surfaces/DiscSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/DiscSurfaceTests.cpp index c2570b82c86..b50a8cfb81c 100644 --- a/Tests/UnitTests/Core/Surfaces/DiscSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/DiscSurfaceTests.cpp @@ -210,7 +210,7 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceProperties) { .closest(); Intersection3D expectedIntersect{Vector3{1.2, 0., 0.}, 10., Intersection3D::Status::reachable}; - BOOST_CHECK(bool(sfIntersection)); + BOOST_CHECK(sfIntersection.isValid()); CHECK_CLOSE_ABS(sfIntersection.position(), expectedIntersect.position(), 1e-9); CHECK_CLOSE_ABS(sfIntersection.pathLength(), expectedIntersect.pathLength(), diff --git a/Tests/UnitTests/Core/Surfaces/IntersectionHelper2DTests.cpp b/Tests/UnitTests/Core/Surfaces/IntersectionHelper2DTests.cpp index a76ec58d6ca..67c3d2a3555 100644 --- a/Tests/UnitTests/Core/Surfaces/IntersectionHelper2DTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/IntersectionHelper2DTests.cpp @@ -32,8 +32,8 @@ void basicChecks(bool circleCase = false) { rY, start, direction) : detail::IntersectionHelper2D::intersectEllipse( rX, rY, start, direction); - BOOST_CHECK(!nosol[0]); - BOOST_CHECK(!nosol[1]); + BOOST_CHECK(!nosol[0].isValid()); + BOOST_CHECK(!nosol[1].isValid()); start = Vector2(4., -4.); auto twosol = circleCase ? detail::IntersectionHelper2D::intersectCircle( @@ -41,8 +41,8 @@ void basicChecks(bool circleCase = false) { : detail::IntersectionHelper2D::intersectEllipse( rX, rY, start, direction); - BOOST_CHECK(twosol[0]); - BOOST_CHECK(twosol[1]); + BOOST_CHECK(twosol[0].isValid()); + BOOST_CHECK(twosol[1].isValid()); start = Vector2(-4., 10.); direction = Vector2(1., 0.); @@ -52,9 +52,9 @@ void basicChecks(bool circleCase = false) { : detail::IntersectionHelper2D::intersectEllipse( rX, rY, start, direction); - BOOST_CHECK(onesolY[0]); + BOOST_CHECK(onesolY[0].isValid()); CHECK_CLOSE_ABS(onesolY[0].position().x(), 0., s_epsilon); - BOOST_CHECK(!onesolY[1]); + BOOST_CHECK(!onesolY[1].isValid()); start = Vector2(rX, -4); direction = Vector2(0., 1.); @@ -64,9 +64,9 @@ void basicChecks(bool circleCase = false) { : detail::IntersectionHelper2D::intersectEllipse( rX, rY, start, direction); - BOOST_CHECK(onesolX[0]); + BOOST_CHECK(onesolX[0].isValid()); CHECK_CLOSE_ABS(onesolX[0].position().y(), 0., s_epsilon); - BOOST_CHECK(!onesolX[1]); + BOOST_CHECK(!onesolX[1].isValid()); } /// Unit test for creating Ellipse intersection @@ -78,13 +78,13 @@ BOOST_AUTO_TEST_CASE(LineLineIntersection) { auto solution = detail::IntersectionHelper2D::intersectSegment( Vector2(5., 3.), Vector2(6., 4), start, dir.normalized()); - BOOST_CHECK(!solution); + BOOST_CHECK(!solution.isValid()); // Possible solution = detail::IntersectionHelper2D::intersectSegment( Vector2(5., 3.), Vector2(3., -1.), start, dir.normalized()); - BOOST_CHECK(solution); + BOOST_CHECK(solution.isValid()); // In principle possible, but out of bound start = Vector2(2, 3); @@ -93,12 +93,12 @@ BOOST_AUTO_TEST_CASE(LineLineIntersection) { solution = detail::IntersectionHelper2D::intersectSegment( Vector2(-1., -2.5), Vector2(3., 2.5), start, dir); - BOOST_CHECK(solution); + BOOST_CHECK(solution.isValid()); solution = detail::IntersectionHelper2D::intersectSegment( Vector2(-1., -2.5), Vector2(3., 2.5), start, dir, true); - BOOST_CHECK(!solution); + BOOST_CHECK(!solution.isValid()); } /// Unit test for creating Ellipse intersection diff --git a/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp b/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp index 8a06a86db04..eb7671e6733 100644 --- a/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp @@ -121,7 +121,7 @@ BOOST_AUTO_TEST_CASE(CylinderIntersectionTests) { BoundaryTolerance::Infinite()); // Check the validity of the intersection - BOOST_CHECK(!iIntersection[0]); + BOOST_CHECK(!iIntersection[0].isValid()); // From edge tests - wo boundary test auto eIntersection = aCylinder->intersect(tgContext, atEdge, transTZ, @@ -151,7 +151,7 @@ BOOST_AUTO_TEST_CASE(CylinderIntersectionTests) { BOOST_CHECK_EQUAL(eIntersection[0].status(), Intersection3D::Status::reachable); // There MUST be a second solution - BOOST_CHECK(!eIntersection[1]); + BOOST_CHECK(!eIntersection[1].isValid()); // The other intersection MUST NOT be reachable BOOST_CHECK_EQUAL(eIntersection[1].status(), Intersection3D::Status::missed); @@ -209,7 +209,7 @@ BOOST_AUTO_TEST_CASE(ConeIntersectionTest) { BoundaryTolerance::Infinite()); // Check the validity of the intersection - BOOST_CHECK(!iIntersection[0]); + BOOST_CHECK(!iIntersection[0].isValid()); }; // In a nominal world @@ -257,7 +257,7 @@ BOOST_AUTO_TEST_CASE(PlanarIntersectionTest) { // The path length MUST be positive BOOST_CHECK_GT(fIntersection[0].pathLength(), 0.); // The intersection MUST be unique - BOOST_CHECK(!fIntersection[1]); + BOOST_CHECK(!fIntersection[1].isValid()); // On surface intersection auto oIntersection = aPlane->intersect(tgContext, onit, direction, @@ -271,7 +271,7 @@ BOOST_AUTO_TEST_CASE(PlanarIntersectionTest) { BOOST_CHECK_LT(std::abs(oIntersection[0].pathLength()), s_onSurfaceTolerance); // The intersection MUST be unique - BOOST_CHECK(!oIntersection[1]); + BOOST_CHECK(!oIntersection[1].isValid()); // Intersect backwards auto bIntersection = aPlane->intersect(tgContext, after, direction, @@ -284,31 +284,31 @@ BOOST_AUTO_TEST_CASE(PlanarIntersectionTest) { // The path length MUST be negative BOOST_CHECK_LT(bIntersection[0].pathLength(), 0.); // The intersection MUST be unique - BOOST_CHECK(!bIntersection[1]); + BOOST_CHECK(!bIntersection[1].isValid()); // An out of bounds attempt: missed auto mIntersection = aPlane->intersect(tgContext, outside, direction, BoundaryTolerance::None()); // The intersection MUST NOT be valid - BOOST_CHECK(!mIntersection[0]); + BOOST_CHECK(!mIntersection[0].isValid()); // The intersection MUST be reachable BOOST_CHECK_EQUAL(mIntersection[0].status(), Intersection3D::Status::missed); // The path length MUST be negative BOOST_CHECK_GT(mIntersection[0].pathLength(), 0.); // The intersection MUST be unique - BOOST_CHECK(!mIntersection[1]); + BOOST_CHECK(!mIntersection[1].isValid()); // An invalid attempt auto iIntersection = aPlane->intersect(tgContext, before, parallel, BoundaryTolerance::None()); // The intersection MUST NOT be valid - BOOST_CHECK(!iIntersection[0]); + BOOST_CHECK(!iIntersection[0].isValid()); // The intersection MUST be reachable BOOST_CHECK_EQUAL(iIntersection[0].status(), Intersection3D::Status::unreachable); // The intersection MUST be unique - BOOST_CHECK(!iIntersection[1]); + BOOST_CHECK(!iIntersection[1].isValid()); }; // In a nominal world @@ -355,7 +355,7 @@ BOOST_AUTO_TEST_CASE(LineIntersectionTest) { // The path length MUST be positive BOOST_CHECK_GT(fIntersection[0].pathLength(), 0.); // The intersection MUST be unique - BOOST_CHECK(!fIntersection[1]); + BOOST_CHECK(!fIntersection[1].isValid()); // On surface intersection - on the straw with random direction auto oIntersection = aLine->intersect(tgContext, onit1, direction, @@ -369,7 +369,7 @@ BOOST_AUTO_TEST_CASE(LineIntersectionTest) { BOOST_CHECK_LT(std::abs(oIntersection[0].pathLength()), s_onSurfaceTolerance); // The intersection MUST be unique - BOOST_CHECK(!oIntersection[1]); + BOOST_CHECK(!oIntersection[1].isValid()); // On surface intersecion - on the surface with normal vector oIntersection = @@ -383,7 +383,7 @@ BOOST_AUTO_TEST_CASE(LineIntersectionTest) { BOOST_CHECK_LT(std::abs(oIntersection[0].pathLength()), s_onSurfaceTolerance); // The intersection MUST be unique - BOOST_CHECK(!oIntersection[1]); + BOOST_CHECK(!oIntersection[1].isValid()); // Intersect backwards auto bIntersection = aLine->intersect(tgContext, after, direction, @@ -396,31 +396,31 @@ BOOST_AUTO_TEST_CASE(LineIntersectionTest) { // The path length MUST be negative BOOST_CHECK_LT(bIntersection[0].pathLength(), 0.); // The intersection MUST be unique - BOOST_CHECK(!bIntersection[1]); + BOOST_CHECK(!bIntersection[1].isValid()); // An out of bounds attempt: missed auto mIntersection = aLine->intersect(tgContext, outside, direction, BoundaryTolerance::None()); // The intersection MUST NOT be valid - BOOST_CHECK(!mIntersection[0]); + BOOST_CHECK(!mIntersection[0].isValid()); // The intersection MUST be reachable BOOST_CHECK_EQUAL(mIntersection[0].status(), Intersection3D::Status::missed); // The path length MUST be negative BOOST_CHECK_LT(mIntersection[0].pathLength(), 0.); // The intersection MUST be unique - BOOST_CHECK(!mIntersection[1]); + BOOST_CHECK(!mIntersection[1].isValid()); // An invalid attempt auto iIntersection = aLine->intersect(tgContext, before, parallel, BoundaryTolerance::None()); // The intersection MUST NOT be valid - BOOST_CHECK(!iIntersection[0]); + BOOST_CHECK(!iIntersection[0].isValid()); // The intersection MUST be reachable BOOST_CHECK_EQUAL(iIntersection[0].status(), Intersection3D::Status::unreachable); // The intersection MUST be unique - BOOST_CHECK(!iIntersection[1]); + BOOST_CHECK(!iIntersection[1].isValid()); }; // In a nominal world diff --git a/Tests/UnitTests/Core/Utilities/IntersectionTests.cpp b/Tests/UnitTests/Core/Utilities/IntersectionTests.cpp index c2f9afe75e2..076abbfe088 100644 --- a/Tests/UnitTests/Core/Utilities/IntersectionTests.cpp +++ b/Tests/UnitTests/Core/Utilities/IntersectionTests.cpp @@ -37,14 +37,14 @@ BOOST_AUTO_TEST_CASE(IntersectionTest) { Intersection3D::Status::reachable); Intersection3D tIp(Vector3(0., 3., 0.), 3., Intersection3D::Status::reachable); - BOOST_CHECK(bool(fIp)); - BOOST_CHECK(bool(sIp)); - BOOST_CHECK(bool(tIp)); + BOOST_CHECK(fIp.isValid()); + BOOST_CHECK(sIp.isValid()); + BOOST_CHECK(tIp.isValid()); // a non-valid intersection Intersection3D nIp(Vector3(3., 3., 0.), 3., Intersection3D::Status::unreachable); - BOOST_CHECK(!bool(nIp)); + BOOST_CHECK(!nIp.isValid()); std::vector fstpIntersections = {fIp, sIp, tIp}; std::vector tsfpIntersections = {tIp, sIp, fIp};