Skip to content
Snippets Groups Projects
Commit b8806fdc authored by Lebrun-Grandie, Damien's avatar Lebrun-Grandie, Damien
Browse files

Deduce geometry tag from Traits::Access::get() return type

parent cc2610e1
No related branches found
No related tags found
1 merge request!115Refactor access traits
This commit is part of merge request !115. Comments created here will be created in the context of that merge request.
......@@ -213,6 +213,25 @@ inline void TreeConstruction<DeviceType>::calculateBoundingBoxOfTheScene(
Kokkos::fence();
}
template <typename Primitives>
struct GeometryTagHelper
{
private:
using accessor_return_type = std::decay_t<decltype(
Traits::Access<Primitives, Traits::PrimitivesTag>::get(
std::declval<Primitives const &>(), std::declval<int>()))>;
static_assert(std::is_same<accessor_return_type, Point>::value ||
std::is_same<accessor_return_type, Box>::value,
"Invalid return type of "
"Traits::Access<Primitives,Traits::PrimitivesTag>::get()");
public:
using tag =
std::conditional_t<std::is_same<accessor_return_type, Point>::value,
PointTag, BoxTag>;
};
template <typename Primitives, typename MortonCodes>
inline void assignMortonCodesDispatch(BoxTag, Primitives const &primitives,
MortonCodes morton_codes,
......@@ -262,7 +281,7 @@ inline void TreeConstruction<DeviceType>::assignMortonCodes(
auto const n = Access::size(primitives);
ARBORX_ASSERT(morton_codes.extent(0) == n);
using Tag = typename Access::Tag;
using Tag = typename GeometryTagHelper<Primitives>::tag;
assignMortonCodesDispatch(Tag{}, primitives, morton_codes,
scene_bounding_box);
}
......@@ -322,7 +341,7 @@ inline void TreeConstruction<DeviceType>::initializeLeafNodes(
"Encoding leaf index in pointer to child is not safe if the "
"index and pointer types do not have the same size");
using Tag = typename Access::Tag;
using Tag = typename GeometryTagHelper<Primitives>::tag;
initializeLeafNodesDispatch(Tag{}, primitives, permutation_indices,
leaf_nodes);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment