Skip to content

Commit

Permalink
Update the code to use convert()
Browse files Browse the repository at this point in the history
  • Loading branch information
aprokop committed Sep 25, 2024
1 parent cc51c9d commit 533f7f4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/ArborX_DBSCAN.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ struct WithinRadiusGetter
{
static_assert(GeometryTraits::is_point_v<Point>);

constexpr int dim = GeometryTraits::dimension_v<Point>;
auto const &hyper_point =
reinterpret_cast<::ArborX::Point<dim> const &>(pair.value);
constexpr int DIM = GeometryTraits::dimension_v<Point>;
using Coordinate = GeometryTraits::coordinate_type_t<Point>;
using ArborX::intersects;
return intersects(Sphere{hyper_point, _r});
return intersects(
Sphere{convert<::ArborX::Point<DIM, Coordinate>>(pair.value), _r});
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ struct approx_expand_by_radius<PointTag, Point>
{
constexpr int DIM = GeometryTraits::dimension_v<Point>;
using Coordinate = GeometryTraits::coordinate_type_t<Point>;
return Sphere{Kokkos::bit_cast<::ArborX::Point<DIM, Coordinate>>(point), r};
return Sphere{Details::convert<::ArborX::Point<DIM, Coordinate>>(point), r};
}
};

Expand Down
7 changes: 3 additions & 4 deletions src/details/ArborX_NeighborList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ struct NeighborListPredicateGetter

constexpr int dim = GeometryTraits::dimension_v<Point>;
using Coordinate = typename GeometryTraits::coordinate_type_t<Point>;

auto const &hyper_point =
reinterpret_cast<::ArborX::Point<dim, Coordinate> const &>(pair.value);
return intersects(Sphere{hyper_point, _radius});
return intersects(
Sphere{Details::convert<::ArborX::Point<dim, Coordinate>>(pair.value),
_radius});
}
};

Expand Down
7 changes: 2 additions & 5 deletions src/details/ArborX_PredicateHelpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,8 @@ struct AccessTraits<Experimental::PrimitivesWithRadius<Primitives>,
using Point = std::decay_t<decltype(point)>;
constexpr int dim = GeometryTraits::dimension_v<Point>;
using Coordinate = typename GeometryTraits::coordinate_type<Point>::type;
// FIXME reinterpret_cast is dangerous here if access traits return user
// point structure (e.g., struct MyPoint { float y; float x; })
auto const &hyper_point =
reinterpret_cast<::ArborX::Point<dim, Coordinate> const &>(point);
return intersects(Sphere(hyper_point, x._r));
return intersects(Sphere(
Details::convert<::ArborX::Point<dim, Coordinate>>(point), x._r));
}
};

Expand Down

0 comments on commit 533f7f4

Please sign in to comment.