diff --git a/AABB_tree/include/CGAL/AABB_tree.h b/AABB_tree/include/CGAL/AABB_tree.h index 91e76c45f96..6558b308494 100644 --- a/AABB_tree/include/CGAL/AABB_tree.h +++ b/AABB_tree/include/CGAL/AABB_tree.h @@ -399,9 +399,9 @@ public: // // `AABBTraits` must be a model of `AABBRayIntersectionTraits` to // call this member function. - template + template boost::optional< typename Intersection_and_primitive_id::Type > - ray_intersection(const Ray& query) const; + ray_intersection(const Ray& query, SkipFunctor skip) const; ///@} @@ -538,9 +538,8 @@ public: ///@} private: - template - friend - class AABB_ray_intersection; + template + friend class AABB_ray_intersection; // clear nodes void clear_nodes() diff --git a/AABB_tree/include/CGAL/internal/AABB_tree/AABB_ray_intersection.h b/AABB_tree/include/CGAL/internal/AABB_tree/AABB_ray_intersection.h index 6f4a8998def..0e1195dcc6f 100644 --- a/AABB_tree/include/CGAL/internal/AABB_tree/AABB_ray_intersection.h +++ b/AABB_tree/include/CGAL/internal/AABB_tree/AABB_ray_intersection.h @@ -32,7 +32,7 @@ namespace CGAL { -template +template class AABB_ray_intersection { typedef typename AABBTree::AABB_traits AABB_traits; typedef typename AABB_traits::Ray_3 Ray; @@ -42,7 +42,7 @@ public: AABB_ray_intersection(const AABBTree& tree) : tree_(tree) {} boost::optional< Ray_intersection_and_primitive_id > - ray_intersection(const Ray& query) const { + ray_intersection(const Ray& query, SkipFunctor skip) const { // We hit the root, now continue on the children. Keep track of // nb_primitives through a variable in each Node on the stack. In // BVH_node::traversal this is done through the function parameter @@ -78,7 +78,7 @@ public: case 2: // Left & right child both leaves { //left child - if(do_intersect_obj(query, current.node->left_data())) { + if(!skip(current.node->left_data().id()) && do_intersect_obj(query, current.node->left_data())) { intersection = intersection_obj(query, current.node->left_data()); if(intersection) { FT ray_distance = boost::apply_visitor(param_visitor, intersection->first); @@ -90,7 +90,7 @@ public: } // right child - if(do_intersect_obj(query, current.node->right_data())) { + if(!skip(current.node->right_data().id()) && do_intersect_obj(query, current.node->right_data())) { intersection = intersection_obj(query, current.node->right_data()); if(intersection) { FT ray_distance = boost::apply_visitor(param_visitor, intersection->first); @@ -104,7 +104,7 @@ public: case 3: // Left child leaf, right child inner node { //left child - if(do_intersect_obj(query, current.node->left_data())) { + if(!skip(current.node->left_data().id()) && do_intersect_obj(query, current.node->left_data())) { intersection = intersection_obj(query, current.node->left_data()); if(intersection) { FT ray_distance = boost::apply_visitor(param_visitor, intersection->first); @@ -179,9 +179,9 @@ private: }; template -template +template boost::optional< typename AABB_tree::template Intersection_and_primitive_id::Type > -AABB_tree::ray_intersection(const Ray& query) const { +AABB_tree::ray_intersection(const Ray& query, SkipFunctor skip) const { CGAL_static_assertion_msg((boost::is_same::value), "Ray and Ray_3 must be the same type"); @@ -193,8 +193,8 @@ AABB_tree::ray_intersection(const Ray& query) const { return traits().intersection_object()(query, singleton_data()); default: // Tree has >= 2 nodes if(traits().do_intersect_object()(query, root_node()->bbox())) { - AABB_ray_intersection< AABB_tree > ri(*this); - return ri.ray_intersection(query); + AABB_ray_intersection< AABB_tree, SkipFunctor > ri(*this); + return ri.ray_intersection(query, skip); } else { // but we don't hit the root break;