| 300 | |
| 301 | template < geode::index_t dimension > |
| 302 | void test_intersections_with_ray_trace() |
| 303 | { |
| 304 | geode::Logger::info( |
| 305 | "TEST", " Box-Ray intersection AABB ", dimension, "D " ); |
| 306 | |
| 307 | const geode::index_t nb_boxes{ 10 }; |
| 308 | const double box_size{ 0.5 }; |
| 309 | const auto box_vector = |
| 310 | create_box_vector< dimension >( nb_boxes, box_size ); |
| 311 | geode::AABBTree< dimension > aabb{ box_vector }; |
| 312 | RayAABBIntersection< dimension > eval_intersection{ box_vector }; |
| 313 | geode::Vector< dimension > ray_direction; |
| 314 | ray_direction.set_value( 1, 1.0 ); |
| 315 | |
| 316 | for( const auto i : geode::Range{ nb_boxes } ) |
| 317 | { |
| 318 | geode::Point< dimension > ray_origin; |
| 319 | ray_origin.set_value( 0, i ); |
| 320 | ray_origin.set_value( 1, i ); |
| 321 | |
| 322 | geode::Ray< dimension > query{ ray_direction, ray_origin }; |
| 323 | |
| 324 | eval_intersection.box_intersections_.clear(); |
| 325 | aabb.compute_ray_element_bbox_intersections( query, eval_intersection ); |
| 326 | |
| 327 | geode::OpenGeodeGeometryException::test( |
| 328 | eval_intersection.box_intersections_.size() == nb_boxes - i, |
| 329 | "Box-Ray intersection - Wrong number of boxes intersected " |
| 330 | "by the ray " ); |
| 331 | |
| 332 | absl::flat_hash_set< geode::index_t > expected_set; |
| 333 | for( const auto c : geode::Range{ nb_boxes - i } ) |
| 334 | { |
| 335 | expected_set.emplace( global_box_index( i, c + i, nb_boxes ) ); |
| 336 | } |
| 337 | |
| 338 | geode::OpenGeodeGeometryException::test( |
| 339 | eval_intersection.box_intersections_ == expected_set, |
| 340 | "Box-Ray intersection - Wrong set of boxes" ); |
| 341 | } |
| 342 | // ray between two boxes |
| 343 | geode::Point< dimension > ray_origin; |
| 344 | ray_origin.set_value( 0, box_size ); |
| 345 | ray_origin.set_value( 1, box_size ); |
| 346 | |
| 347 | geode::Ray< dimension > query{ ray_direction, ray_origin }; |
| 348 | |
| 349 | eval_intersection.box_intersections_.clear(); |
| 350 | aabb.compute_ray_element_bbox_intersections( query, eval_intersection ); |
| 351 | |
| 352 | geode::OpenGeodeGeometryException::test( |
| 353 | eval_intersection.box_intersections_.size() == 2 * nb_boxes, |
| 354 | "Box-Ray intersection - Wrong number of boxes intersected by " |
| 355 | "the ray " ); |
| 356 | absl::flat_hash_set< geode::index_t > expected_set; |
| 357 | for( const auto c : geode::Range{ nb_boxes } ) |
| 358 | { |
| 359 | expected_set.emplace( global_box_index( 0, c, nb_boxes ) ); |
nothing calls this directly
no test coverage detected