mirror of https://github.com/CGAL/cgal
AABB tree: more on distance queries
it remains to fix the Distance_traits
This commit is contained in:
parent
c26e8531e1
commit
154ff8cfa0
|
|
@ -55,7 +55,7 @@ int main(void)
|
||||||
// constructs the AABB tree and the internal search tree for
|
// constructs the AABB tree and the internal search tree for
|
||||||
// efficient projection computations.
|
// efficient projection computations.
|
||||||
Tree tree(polyhedron.edges_begin(),polyhedron.edges_end());
|
Tree tree(polyhedron.edges_begin(),polyhedron.edges_end());
|
||||||
tree.construct_search_tree();
|
tree.accelerate_distance_queries();
|
||||||
|
|
||||||
// counts #intersections with a triangle
|
// counts #intersections with a triangle
|
||||||
Triangle triangle(p,q,r);
|
Triangle triangle(p,q,r);
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ int main(void)
|
||||||
// constructs the AABB tree and the internal search tree for
|
// constructs the AABB tree and the internal search tree for
|
||||||
// efficient projection computations.
|
// efficient projection computations.
|
||||||
Tree tree(segments.begin(),segments.end());
|
Tree tree(segments.begin(),segments.end());
|
||||||
tree.construct_search_tree();
|
tree.accelerate_distance_queries();
|
||||||
|
|
||||||
// counts #intersections with a plane
|
// counts #intersections with a plane
|
||||||
Plane plane(a,b,d);
|
Plane plane(a,b,d);
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ public:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef typename std::pair<Object,Primitive> Object_and_primitive;
|
typedef typename std::pair<Object,Primitive> Object_and_primitive;
|
||||||
|
typedef typename std::pair<Point,Primitive> Point_and_primitive;
|
||||||
|
|
||||||
// types for search tree
|
// types for search tree
|
||||||
// TOFIX: how can we avoid repeating those?
|
// TOFIX: how can we avoid repeating those?
|
||||||
|
|
|
||||||
|
|
@ -134,9 +134,9 @@ namespace CGAL {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
// clears internal KD tree
|
||||||
void clear_search_tree()
|
void clear_search_tree()
|
||||||
{
|
{
|
||||||
// clear KD tree
|
|
||||||
delete m_p_search_tree;
|
delete m_p_search_tree;
|
||||||
m_p_search_tree = NULL;
|
m_p_search_tree = NULL;
|
||||||
m_search_tree_constructed = false;
|
m_search_tree_constructed = false;
|
||||||
|
|
@ -347,9 +347,11 @@ namespace CGAL {
|
||||||
|
|
||||||
void intersection(const Point& query, const Primitive& primitive)
|
void intersection(const Point& query, const Primitive& primitive)
|
||||||
{
|
{
|
||||||
|
// TOFIX
|
||||||
// update m_closest_primitive if needed
|
// update m_closest_primitive if needed
|
||||||
Point new_closest_point = AABBTraits().closest_point(query, primitive, m_closest_point)
|
Point new_closest_point =
|
||||||
if(new_closest_point != )
|
AABBTraits().closest_point(query, primitive, m_closest_point);
|
||||||
|
if(new_closest_point != m_closest_point)
|
||||||
{
|
{
|
||||||
m_closest_primitive = primitive;
|
m_closest_primitive = primitive;
|
||||||
m_closest_point = new_closest_point;
|
m_closest_point = new_closest_point;
|
||||||
|
|
@ -378,11 +380,6 @@ namespace CGAL {
|
||||||
CGAL_assertion(!empty());
|
CGAL_assertion(!empty());
|
||||||
return m_data[0].reference_point();
|
return m_data[0].reference_point();
|
||||||
}
|
}
|
||||||
Primitive any_primitive()
|
|
||||||
{
|
|
||||||
CGAL_assertion(!empty());
|
|
||||||
return m_data[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Point best_hint(const Point& query)
|
Point best_hint(const Point& query)
|
||||||
|
|
@ -496,7 +493,7 @@ namespace CGAL {
|
||||||
{
|
{
|
||||||
CGAL_assertion(!m_data.empty());
|
CGAL_assertion(!m_data.empty());
|
||||||
|
|
||||||
// iterate over primitives to get points on them
|
// iterate over primitives to get reference points on them
|
||||||
std::vector<Point> points;
|
std::vector<Point> points;
|
||||||
typename std::vector<Primitive>::const_iterator it;
|
typename std::vector<Primitive>::const_iterator it;
|
||||||
for(it = m_data.begin(); it != m_data.end(); ++it)
|
for(it = m_data.begin(); it != m_data.end(); ++it)
|
||||||
|
|
@ -573,7 +570,8 @@ namespace CGAL {
|
||||||
AABB_tree<Tr>::closest_point(const Point& query,
|
AABB_tree<Tr>::closest_point(const Point& query,
|
||||||
const Point& hint)
|
const Point& hint)
|
||||||
{
|
{
|
||||||
Distance_traits distance_traits(query,hint);
|
Primitive hint_primitive = m_data[0];
|
||||||
|
Distance_traits distance_traits(query,hint,hint_primitive);
|
||||||
this->traversal(query, distance_traits);
|
this->traversal(query, distance_traits);
|
||||||
return distance_traits.closest_point();
|
return distance_traits.closest_point();
|
||||||
}
|
}
|
||||||
|
|
@ -584,7 +582,7 @@ namespace CGAL {
|
||||||
typename AABB_tree<Tr>::Point
|
typename AABB_tree<Tr>::Point
|
||||||
AABB_tree<Tr>::closest_point(const Point& query)
|
AABB_tree<Tr>::closest_point(const Point& query)
|
||||||
{
|
{
|
||||||
const Point hint = best_hint();
|
const Point hint = best_hint(query);
|
||||||
return closest_point(query,hint);
|
return closest_point(query,hint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -610,19 +608,18 @@ namespace CGAL {
|
||||||
// closest point with user-specified hint
|
// closest point with user-specified hint
|
||||||
template<typename Tr>
|
template<typename Tr>
|
||||||
typename AABB_tree<Tr>::Primitive
|
typename AABB_tree<Tr>::Primitive
|
||||||
AABB_tree<Tr>::closest_primitive(const Point& query)
|
AABB_tree<Tr>::closest_primitive(const Point& query) const
|
||||||
{
|
{
|
||||||
const Point hint = best_hint();
|
return closest_primitive(query,best_hint(query));
|
||||||
return closest_primitive(query,hint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// closest point with user-specified hint
|
// closest point with user-specified hint
|
||||||
template<typename Tr>
|
template<typename Tr>
|
||||||
typename AABB_tree<Tr>::Primitive
|
typename AABB_tree<Tr>::Primitive
|
||||||
AABB_tree<Tr>::closest_primitive(const Point& query,
|
AABB_tree<Tr>::closest_primitive(const Point& query,
|
||||||
const Point& hint)
|
const Point& hint) const
|
||||||
{
|
{
|
||||||
const Point hint = best_hint();
|
const Point hint = best_hint(query);
|
||||||
Distance_traits distance_traits(query,hint,any_primitive());
|
Distance_traits distance_traits(query,hint,any_primitive());
|
||||||
this->traversal(query, distance_traits);
|
this->traversal(query, distance_traits);
|
||||||
return distance_traits.closest_primitive();
|
return distance_traits.closest_primitive();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue