diff --git a/src/geometry/ArborX_Point.hpp b/src/geometry/ArborX_Point.hpp index 76a7ed17a..ef2bd7261 100644 --- a/src/geometry/ArborX_Point.hpp +++ b/src/geometry/ArborX_Point.hpp @@ -35,11 +35,15 @@ struct Point Coordinate _coords[DIM] = {}; }; -template -Point(T...) - -> Point, double>), - double, float>>; +template +Point(T, Ts...) -> Point< + sizeof...(Ts) + 1, + std::conditional_t< + std::is_integral_v> && + (... && std::is_integral_v>), + double, + std::enable_if_t< + (... && std::is_same_v, std::decay_t>), T>>>; } // namespace ArborX diff --git a/test/tstCompileOnlyGeometry.cpp b/test/tstCompileOnlyGeometry.cpp index 62b69b5ca..25b78b402 100644 --- a/test/tstCompileOnlyGeometry.cpp +++ b/test/tstCompileOnlyGeometry.cpp @@ -232,16 +232,20 @@ void test_point_cv_compile_only() void test_point_ctad() { using ArborX::Point; - static_assert(std::is_same_v>); + + static_assert(std::is_same_v>); static_assert(std::is_same_v>); - static_assert(std::is_same_v>); - static_assert(std::is_same_v>); - static_assert(std::is_same_v>); - static_assert(std::is_same_v>); + static_assert(std::is_same_v>); + static_assert( + std::is_same_v>); static_assert( std::is_same_v>); + static_assert( + std::is_same_v{1, 4}), Point<2, float>>); static_assert( std::is_same_v{2, 3, 2}), Point<3, int>>); + static_assert(std::is_same_v{2.f, 3.f, 2.f}), + Point<3, double>>); } } // namespace ArborX::GeometryTraits diff --git a/test/tstRay.cpp b/test/tstRay.cpp index f0cce5dce..f169b2506 100644 --- a/test/tstRay.cpp +++ b/test/tstRay.cpp @@ -415,8 +415,8 @@ BOOST_AUTO_TEST_CASE(intersects_triangle) using ArborX::Point; using ArborX::Experimental::Ray; using ArborX::ExperimentalHyperGeometry::Triangle; - constexpr Triangle unit_triangle{Point{0, 0, 0}, Point{1, 0, 0}, - Point{0, 1, 0}}; + constexpr Triangle unit_triangle{Point{0.f, 0.f, 0.f}, Point{1.f, 0.f, 0.f}, + Point{0.f, 1.f, 0.f}}; BOOST_TEST(intersects(Ray{{.1, .2, .3}, {0, 0, -1}}, unit_triangle)); BOOST_TEST(intersects(Ray{{1.1, 1.2, 1}, {-1, -1, -1}}, unit_triangle)); @@ -462,8 +462,8 @@ BOOST_AUTO_TEST_CASE(intersects_triangle) // ray in a plane parallel to the triangle BOOST_TEST(!intersects(Ray{{-0.1, 0, 1}, {1, 0, 0}}, unit_triangle)); - constexpr Triangle tilted_triangle{Point{0, 0, 0}, Point{2, 0, 1}, - Point{0, 2, 1}}; + constexpr Triangle tilted_triangle{Point{0.f, 0.f, 0.f}, Point{2.f, 0.f, 1.f}, + Point{0.f, 2.f, 1.f}}; // ray in the same plane as the triangle BOOST_TEST(!intersects(Ray{{10, 0, 0}, {1, 1, 1}}, tilted_triangle)); @@ -506,10 +506,10 @@ BOOST_AUTO_TEST_CASE(ray_triangle_intersection, constexpr auto inf = KokkosExt::ArithmeticTraits::infinity::value; #endif - constexpr Triangle unit_triangle{Point{0, 0, 0}, Point{1, 0, 0}, - Point{0, 1, 0}}; - constexpr Triangle narrow_triangle{Point{0.5f, 0.5f, 0}, - Point{0.24f, 0.74f, 0}, Point{0, 1.f, 0}}; + constexpr Triangle unit_triangle{Point{0.f, 0.f, 0.f}, Point{1.f, 0.f, 0.f}, + Point{0.f, 1.f, 0.f}}; + constexpr Triangle narrow_triangle{ + Point{0.5f, 0.5f, 0.f}, Point{0.24f, 0.74f, 0.f}, Point{0.f, 1.f, 0.f}}; auto const sqrtf_3 = std::sqrt(3.f); auto const sqrtf_2 = std::sqrt(2.f); @@ -563,10 +563,10 @@ BOOST_AUTO_TEST_CASE(ray_triangle_intersection, // test would fail the "Plucker coordinates"-based algorithm, thus it is necessary to // keep them here to show the watertightness of the current algorithm implemented. constexpr Point O{1.f, 1.f, 1.f}; - constexpr Point A{2.f, 2.f, 0}; - constexpr Point B{2.f, -1.f, 0}; - constexpr Point C{-1.f, -1.f, 0}; - constexpr Point D{-1.f, 2.f, 0}; + constexpr Point A{2.f, 2.f, 0.f}; + constexpr Point B{2.f, -1.f, 0.f}; + constexpr Point C{-1.f, -1.f, 0.f}; + constexpr Point D{-1.f, 2.f, 0.f}; constexpr Triangle triangle_up{D, A, O}; constexpr Triangle triangle_right{O, A, B}; @@ -599,12 +599,12 @@ BOOST_AUTO_TEST_CASE(ray_triangle_intersection, // between the origin of the ray and the vertices. // These tests will fail if there is no normalization. float const size_s = 0.0001; - Triangle small_triangle{Point{-size_s, 0, 0}, Point{0, size_s, 0}, Point{0, 0, size_s}}; + Triangle small_triangle{Point{-size_s, 0.f, 0.f}, Point{0.f, size_s, 0.f}, Point{0.f, 0.f, size_s}}; ARBORX_TEST_RAY_TRIANGLE_INTERSECTION((Ray{{0.0, 0.0, 0.0}, {-size_s, size_s, size_s}}), small_triangle, size_s/sqrtf_3, size_s/sqrtf_3); ARBORX_TEST_RAY_TRIANGLE_INTERSECTION((Ray{{-2.f*size_s, -size_s, 0.0}, {size_s, size_s, 0}}), small_triangle, sqrtf_2*size_s, 2.f*sqrtf_2*size_s); float const size_l = 10000; - Triangle large_triangle{Point{-size_l, 0, 0}, Point{0, 10000, 0}, Point{0, 0, 10000}}; + Triangle large_triangle{Point{-size_l, 0.f, 0.f}, Point{0.f, 10000.f, 0.f}, Point{0.f, 0.f, 10000.f}}; ARBORX_TEST_RAY_TRIANGLE_INTERSECTION((Ray{{0.0, 0.0, 0.0}, {-size_l, size_l, size_l}}), large_triangle, size_l/sqrtf_3, size_l/sqrtf_3); ARBORX_TEST_RAY_TRIANGLE_INTERSECTION((Ray{{-2.f*size_l, -size_l, 0.0}, {size_l, size_l, 0}}), large_triangle, sqrtf_2*size_l, 2.f*sqrtf_2*size_l);