diff --git a/AABB_tree/include/CGAL/AABB_tree.h b/AABB_tree/include/CGAL/AABB_tree.h index 9c2d43fadae..9020a2e76c9 100644 --- a/AABB_tree/include/CGAL/AABB_tree.h +++ b/AABB_tree/include/CGAL/AABB_tree.h @@ -336,6 +336,12 @@ public: template bool do_intersect(const Query& query) const; + template + bool do_intersect_join(const AABB_tree &other, + const Point &Translation_point, + const Primitive_type &p, + const Primitive_type &q) const; + /// Returns the number of primitives intersected by the /// query. \tparam Query must be a type for which /// `do_intersect` predicates are defined @@ -568,6 +574,16 @@ public: } } + template + void join_traversal(const AABB_tree &other_tree, Traversal_traits &traits) const + { + if (!empty() && !other_tree.empty()) { + root_node()->template join_traversal(*(other_tree.root_node()), traits, m_primitives.size(), other_tree.m_primitives.size(), true); + } else { + std::cerr << "AABB tree join traversal with empty tree" << std::endl; + } + } + private: typedef AABB_node Node; @@ -1082,6 +1098,20 @@ public: return traversal_traits.is_intersection_found(); } + template + template + bool + AABB_tree::do_intersect_join(const AABB_tree &other, + const Point &Translation_point, + const Primitive_type &p, + const Primitive_type &q) const { + using namespace CGAL::internal::AABB_tree; + typedef typename AABB_tree::AABB_traits AABBTraits; + Do_intersect_joined_traits traversal_traits(Translation_point, p, q); + this->join_traversal(other, traversal_traits); + return traversal_traits.is_intersection_found(); + } + template template typename AABB_tree::size_type diff --git a/AABB_tree/include/CGAL/internal/AABB_tree/AABB_traversal_traits.h b/AABB_tree/include/CGAL/internal/AABB_tree/AABB_traversal_traits.h index 793631ae347..575dca2ead3 100644 --- a/AABB_tree/include/CGAL/internal/AABB_tree/AABB_traversal_traits.h +++ b/AABB_tree/include/CGAL/internal/AABB_tree/AABB_traversal_traits.h @@ -284,6 +284,73 @@ private: }; +template +class Do_intersect_joined_traits { + typedef typename AABBTraits::Point_3 Point; + typedef typename AABBTraits::Primitive Primitive; + typedef ::CGAL::AABB_node Node; +public: + Do_intersect_joined_traits(const Point &point, const Primitive_type &p, const Primitive_type &q) + : m_is_found(false) , m_point(point) { + m_traits_ptr = new AABBTraits(point, p, q); + } + + bool go_further() const { + return !m_is_found; + } + + void intersection(const Primitive &primitive1, const Primitive &primitive2, bool toSwitch) { + if (!toSwitch) { + if (m_traits_ptr->do_intersect_object()(primitive1, primitive2)) { + m_is_found = true; + } + } else { + if (m_traits_ptr->do_intersect_object()(primitive2, primitive1)) { + m_is_found = true; + } + } + } + + bool do_intersect(const Node &node_1, const Node &node_2, bool toSwitch) const { + if (!toSwitch) { + return m_traits_ptr->do_intersect_object()(node_1.bbox(), node_2.bbox()); + } else { + return m_traits_ptr->do_intersect_object()(node_2.bbox(), node_1.bbox()); + } + } + + bool do_intersect(const Node &node_1, const Primitive &primitive2, bool toSwitch) const { + if (!toSwitch) { + return m_traits_ptr->do_intersect_object()(node_1.bbox(), primitive2); + } else { + return m_traits_ptr->do_intersect_object()(primitive2, node_1.bbox()); + } + } + + bool do_intersect(const Primitive &primitive1, const Node &node_2, bool toSwitch) const { + if (!toSwitch) { + return m_traits_ptr->do_intersect_object()(primitive1, node_2.bbox()); + } else { + return m_traits_ptr->do_intersect_object()(node_2.bbox(), primitive1); + } + } + + bool is_intersection_found() const { + return m_is_found; + } + + ~Do_intersect_joined_traits() { + delete m_traits_ptr; + } + +private: + bool m_is_found; + Point m_point; + //Primitive_type& m_p,m_q; + AABBTraits *m_traits_ptr; +}; + + /** * @class Projection_traits */ diff --git a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/new/aabb/AABB_collision_detector_2.h b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/new/aabb/AABB_collision_detector_2.h index 9cd6af2f771..24be327a69e 100644 --- a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/new/aabb/AABB_collision_detector_2.h +++ b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/new/aabb/AABB_collision_detector_2.h @@ -1,7 +1,7 @@ #ifndef CGAL_AABB_COLLISION_DETECTOR_2_H #define CGAL_AABB_COLLISION_DETECTOR_2_H -#include +#include #include #include @@ -17,7 +17,7 @@ public: typedef typename Polygon_2::Edge_const_iterator Edge_iterator; typedef AABB_segment_2_primitive Tree_segment_2; typedef AABB_traits_2 Tree_traits; - typedef AABB_tree_2 Tree_2; + typedef AABB_tree Tree_2; public: