mirror of https://github.com/CGAL/cgal
Put do_intersect_join into AABB_tree package
This commit is contained in:
parent
c95387785b
commit
2f9b4cdff9
|
|
@ -336,6 +336,12 @@ public:
|
|||
template<typename Query>
|
||||
bool do_intersect(const Query& query) const;
|
||||
|
||||
template<typename Primitive_type>
|
||||
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 <class Traversal_traits>
|
||||
void join_traversal(const AABB_tree &other_tree, Traversal_traits &traits) const
|
||||
{
|
||||
if (!empty() && !other_tree.empty()) {
|
||||
root_node()->template join_traversal<Traversal_traits>(*(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<AABBTraits> Node;
|
||||
|
||||
|
|
@ -1082,6 +1098,20 @@ public:
|
|||
return traversal_traits.is_intersection_found();
|
||||
}
|
||||
|
||||
template<typename Tr>
|
||||
template<typename Primitive_type>
|
||||
bool
|
||||
AABB_tree<Tr>::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<Tr>::AABB_traits AABBTraits;
|
||||
Do_intersect_joined_traits<AABBTraits, Primitive_type> traversal_traits(Translation_point, p, q);
|
||||
this->join_traversal(other, traversal_traits);
|
||||
return traversal_traits.is_intersection_found();
|
||||
}
|
||||
|
||||
template<typename Tr>
|
||||
template<typename Query>
|
||||
typename AABB_tree<Tr>::size_type
|
||||
|
|
|
|||
|
|
@ -284,6 +284,73 @@ private:
|
|||
};
|
||||
|
||||
|
||||
template<typename AABBTraits, typename Primitive_type>
|
||||
class Do_intersect_joined_traits {
|
||||
typedef typename AABBTraits::Point_3 Point;
|
||||
typedef typename AABBTraits::Primitive Primitive;
|
||||
typedef ::CGAL::AABB_node<AABBTraits> 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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef CGAL_AABB_COLLISION_DETECTOR_2_H
|
||||
#define CGAL_AABB_COLLISION_DETECTOR_2_H
|
||||
|
||||
#include <CGAL/Minkowski_sum_2/new/aabb/AABB_tree_2.h>
|
||||
#include <CGAL/AABB_tree.h>
|
||||
#include <CGAL/Minkowski_sum_2/new/aabb/AABB_traits_2.h>
|
||||
#include <CGAL/Minkowski_sum_2/new/aabb/AABB_segment_2_primitive.h>
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ public:
|
|||
typedef typename Polygon_2::Edge_const_iterator Edge_iterator;
|
||||
typedef AABB_segment_2_primitive<Kernel_, Edge_iterator, Polygon_2> Tree_segment_2;
|
||||
typedef AABB_traits_2<Kernel_, Tree_segment_2> Tree_traits;
|
||||
typedef AABB_tree_2<Tree_traits> Tree_2;
|
||||
typedef AABB_tree<Tree_traits> Tree_2;
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue