diff --git a/include/double_down/RTI.hpp b/include/double_down/RTI.hpp index de5a539..180224a 100644 --- a/include/double_down/RTI.hpp +++ b/include/double_down/RTI.hpp @@ -101,6 +101,11 @@ class RayTracingInterface { //! \brief Release all Embree scenes and device. void shutdown(); + moab::ErrorCode + find_volume(const double xyz[3], + moab::EntityHandle& volume, + double* uvw=nullptr); + //! \brief Check location \p xyz for containment in the specified \p volume. //! Performs a point containment query by firing a single ray and checking the dot product //! of the ray direction and the sense-adjusted normal of the triangle hit. Falls back onto diff --git a/src/RTI.cpp b/src/RTI.cpp index 40dc065..f534ca8 100644 --- a/src/RTI.cpp +++ b/src/RTI.cpp @@ -696,6 +696,22 @@ RayTracingInterface::point_in_volume_slow(moab::EntityHandle volume, return MB_SUCCESS; } +moab::ErrorCode +RayTracingInterface::find_volume(const double xyz[3], + moab::EntityHandle& volume, + double* uvw) { + int result = 0; + for (int i = 0; i < GTT->num_entities(3); i++) { + moab::EntityHandle vol = GTT->entity_by_index(3, i); + point_in_volume(vol, xyz, result, uvw); + if (result == 1) { + volume = vol; + break; + } + } + return moab::MB_SUCCESS; +} + moab::ErrorCode RayTracingInterface::point_in_volume(const moab::EntityHandle volume, const double xyz[3],