mirror of https://github.com/CGAL/cgal
AABB tree: started to implement new API
CAREFUL: does not compile anymore - will fix this next week.
This commit is contained in:
parent
b75a57f5b8
commit
23f94c802b
Binary file not shown.
|
|
@ -27,15 +27,11 @@ The concept \ccRefName\ provides the geometric primitive types and methods for t
|
|||
\ccGlue
|
||||
\ccNestedType{Bounding_box}{Bounding box type.}
|
||||
\ccGlue
|
||||
\ccNestedType{Intersection}{Type of intersection.}
|
||||
\ccNestedType{Point_and_primitive}{Pair composed of a point and a primitive.}
|
||||
|
||||
The following types are required for projection queries.
|
||||
The following types are required for distance queries.
|
||||
|
||||
\ccNestedType{Sphere}{Sphere type.}
|
||||
\ccGlue
|
||||
\ccNestedType{Projection_query}{Type for which projection queries are issued.}
|
||||
\ccGlue
|
||||
\ccNestedType{Projection}{Type of projection result.}
|
||||
|
||||
|
||||
\ccCreation
|
||||
|
|
@ -69,19 +65,11 @@ for which the class \ccc{AABB_tree<Traits>} may receive a query.
|
|||
% TODO: replace return by pair<bool,Intersection>
|
||||
\ccMethod{bool intersection(const Query & q,
|
||||
const Primitive& primitive,
|
||||
Intersection & intersection);}
|
||||
{Returns \ccc{true} iff the query intersects the primitive. In the positive, stores the intersection in the last parameter. }
|
||||
Point_and_primitive& result);}
|
||||
{Returns \ccc{true} iff the query intersects the primitive. In the positive, stores the intersection in the last parameter as a pair composed of a point and a primitive. }
|
||||
|
||||
The following members are required only if projection queries are issued.
|
||||
\ccMethod{Sphere sphere_from_query_and_hint(const Projection_query & center,
|
||||
const Projection & hint);}
|
||||
{Returns a sphere centered at \ccc{center} and passing through \ccc{hint}.}
|
||||
% TODO: document nearest_point
|
||||
|
||||
% TODO: replace return by pair<bool,Intersection>
|
||||
\ccMethod{ bool intersection(const Sphere & sphere,
|
||||
const Primitive::Object object,
|
||||
const Projection & projection);}
|
||||
{Returns \ccc{true} iff the primitive object is intersecting the ball defined as the interior of the sphere. In the positive, the point of the primitive closest to the center of the sphere is stored in the last parameter.}
|
||||
|
||||
\ccMethod{bool is_contained(const Sphere & a, const Sphere & b);}{Returns \ccc{true} iff sphere $a$ is contained in sphere $b$. Both spheres are assumed to share the same center.}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,11 +31,14 @@ The class \ccRefName\ is a static data structure for efficient intersection and
|
|||
\ccTypedef{typedef Traits::Point_3 Point;}
|
||||
{Type of 3D point.}
|
||||
\ccGlue
|
||||
\ccNestedType{Primitive}
|
||||
{Type of input primitives.}
|
||||
\ccTypedef{typedef Traits::Primitive Primitive;}
|
||||
{Type of input primitive.}
|
||||
\ccGlue
|
||||
\ccTypedef{typedef Traits::Bounding_box Bounding_box;}
|
||||
{Type of bounding box.}
|
||||
\ccGlue
|
||||
\ccNestedType{Point_and_primitive}
|
||||
{A pair composed of a Point and a Primitive.}
|
||||
{A pair composed of a point and a primitive.}
|
||||
|
||||
%\ccNestedType{AABB}{some nested types}
|
||||
|
||||
|
|
@ -45,42 +48,40 @@ The class \ccRefName\ is a static data structure for efficient intersection and
|
|||
\ccConstructor{AABB_tree();}{Default constructor.}
|
||||
\ccConstructor{template < class ConstPrimitiveIterator>
|
||||
AABB_tree( ConstPrimitiveIterator begin,
|
||||
ConstPrimitiveIterator beyond,
|
||||
const bool construct_search_tree = false);}
|
||||
{Builds the datastructure. Type \ccc{ConstPrimitiveIterator} can be any const iterator on a container of \ccc{Primitive::Object} such that \ccc{Primitive} has a constructor taking a \ccc{ConstPrimitiveIterator} as argument. Flag \ccc{construct_search_tree} indicates if the search KD-tree used to accelerate the distance queries must be computed during the construction of the AABB tree. In the negative each distance query called without any hint takes the first primitive reference point as hint and is hence slower (the flag is a mean to trade efficiency for memory). }
|
||||
ConstPrimitiveIterator beyond);}
|
||||
{Builds the datastructure. Type \ccc{ConstPrimitiveIterator} can be any const iterator on a container of \ccc{Primitive::Object} such that \ccc{Primitive} has a constructor taking a \ccc{ConstPrimitiveIterator} as argument.}
|
||||
|
||||
\ccOperations
|
||||
|
||||
\ccMethod{template < class ConstPrimitiveIterator>
|
||||
bool clear_and_insert(ConstPrimitiveIterator begin,
|
||||
ConstPrimitiveIterator beyond,
|
||||
const bool construct_search_tree = false);}
|
||||
{Clears the current tree and rebuilds it from scratch (see constructor \ccc{AABB_tree(begin,beyond)} above for the parameters). Returns \ccc{true} iff the memory allocation was successful. }
|
||||
ConstPrimitiveIterator beyond);}
|
||||
{Clears the current tree and rebuilds it from scratch. See constructor above for the parameters. Returns \ccc{true} iff the memory allocation is successful. }
|
||||
|
||||
\ccMethod{void clear(void);}
|
||||
{Clears the current tree. }
|
||||
{Clears the AABB tree. }
|
||||
|
||||
% INTERSECTION TESTS
|
||||
\ccHeading{Intersection Tests}
|
||||
|
||||
\ccMethod{ template <class Query>
|
||||
bool do_intersect(const Query & q);}
|
||||
{ Returns \ccc{true} iff the query intersects the primitives. Type \ccc{Query} has to be a type for which \ccc{do_intersect} predicates have been defined in \ccc{Traits}.}
|
||||
\ccMethod{template <class Query>
|
||||
bool do_intersect(const Query& query);}
|
||||
{ Returns \ccc{true} iff the query intersects the input primitives. Type \ccc{Query} must be a type for which \ccc{do_intersect} predicates are defined in the \ccc{Traits}.}
|
||||
|
||||
\ccMethod{template <class Query>
|
||||
size_t number_of_intersections(const Query& q );}
|
||||
{Returns the number of primitives intersected by the query. Type \ccc{Query} has to be a type for which \ccc{do_intersect} predicates have been defined in \ccc{Traits}.}
|
||||
size_t number_of_intersections(const Query& query);}
|
||||
{Returns the number of intersections between the query and the input primitives. Type \ccc{Query} must be a type for which \ccc{do_intersect} predicates are defined in the \ccc{Traits}.}
|
||||
|
||||
\ccMethod{template <class Query, class OutputIterator>
|
||||
OutputIterator
|
||||
all_intersected_primitives(const Query& query, OutputIterator out);}
|
||||
{Outputs to the iterator the list of intersected primitives. This function does not compute the intersection points and is hence faster than the function \ccc{all_intersections}. Type \ccc{Query} must be a type for which \ccc{do_intersect} predicates have been defined in \ccc{Traits}. The value type of OutputIterator is assumed to be \ccc{Primitive}.}
|
||||
all_intersected_primitives(const Query& query,
|
||||
OutputIterator out);}
|
||||
{Outputs to the iterator the list of all intersected primitives. This function does not compute the intersection points and is hence faster than the function \ccc{all_intersections} function below. Type \ccc{Query} must be a type for which \ccc{do_intersect} predicates are defined in the \ccc{Traits}.}
|
||||
|
||||
|
||||
\ccMethod{template <class Query, class OutputIterator>
|
||||
\ccMethod{template <class Query>
|
||||
bool any_intersected_primitive(const Query& query,
|
||||
Primitive& primitive);}
|
||||
{Return \ccc{true} iff the query intersects the primitive. In the positive, saves the first encountered primitive to the second parameter. Type \ccc{Query} has to be a type for which \ccc{do_intersect} and intersection predicates have been defined in \ccc{Traits}.}
|
||||
{Return \ccc{true} iff the query intersects at least one of the input primitives. In the positive, saves the first encountered primitive to the second parameter. Type \ccc{Query} must be a type for which \ccc{do_intersect} and intersection predicates are defined in the \ccc{Traits}.}
|
||||
|
||||
% INTERSECTIONS
|
||||
\ccHeading{Intersections}
|
||||
|
|
@ -89,15 +90,12 @@ bool any_intersected_primitive(const Query& query,
|
|||
OutputIterator
|
||||
all_intersections(const Query& query,
|
||||
OutputIterator out);}
|
||||
{Outputs to the iterator the list of all intersections between the query and input data. Type \ccc{Query} must be a type for which \ccc{do_intersect} predicates have been defined in \ccc{Traits}. The value type of OutputIterator is assumed to be \ccc{Point_and_primitive}.}
|
||||
|
||||
% ( Note : output iterators have "void" as value_type, so you should better write "and output them to the output iterator pts, as objects of type...".)
|
||||
|
||||
{Outputs to the iterator the list of all intersections between the query and input data, as objects of type \ccc{Point_and_primitive}. Type \ccc{Query} must be a type for which \ccc{do_intersect} predicates and intersections are defined in the \ccc{Traits}.}
|
||||
|
||||
\ccMethod{template <class Query>
|
||||
bool any_intersection(const Query& query,
|
||||
Intersection& intersection);}
|
||||
{Returns \ccc{true} iff the query intersects the primitives. In the positive, saves the first encountered intersection to the second parameter. Type \ccc{Query} has to be a type for which \ccc{do_intersect} and intersection predicates have been defined in \ccc{Traits}.}
|
||||
Point_and_primitive& point_and_primitive);}
|
||||
{Returns \ccc{true} iff the query intersects at least one of the input primitives. In the positive, saves the first encountered intersection to the second parameter. Type \ccc{Query} must be a type for which \ccc{do_intersect} predicates and intersections are defined in the \ccc{Traits}.}
|
||||
|
||||
|
||||
% DISTANCE QUERIES
|
||||
|
|
@ -106,7 +104,7 @@ bool any_intersection(const Query& query,
|
|||
\ccMethod{Point
|
||||
closest_point(const Point& query,
|
||||
const Point& hint);}
|
||||
{Returns the point on all input primitives which is closest to the query. In case of several points located at the same (closest) distance one arbitrarily chosen is returned. Parameter \ccc{hint} is assumed to be any point located on the input primitives (the closer \ccc{hint} to \ccc{query}, the faster the query). Parameter \ccc{hint} can be omitted. If the internal KD-tree data structure has been constructed it is used to efficiently query the nearest hint point from the query. Otherwise a naive hint point is taken as the first primitive reference point. }
|
||||
{Returns the point on all input primitives which is closest to the query. In case of several closest points one arbitrarily chosen point is returned. Parameter \ccc{hint} is assumed to be any point located on the input primitives (the closer \ccc{hint} to \ccc{query}, the faster). Parameter \ccc{hint} can be omitted. If the internal KD-tree data structure has been constructed using function \ccc{construct_search_tree} (see below), it is used to efficiently query the nearest hint point from the query. Otherwise a naive hint point is taken as the first primitive reference point. }
|
||||
|
||||
\ccMethod{Primitive
|
||||
closest_primitive(const Point& query,
|
||||
|
|
@ -116,24 +114,25 @@ closest_primitive(const Point& query,
|
|||
\ccMethod{Point_and_primitive
|
||||
closest_point_and_primitive(const Point& query,
|
||||
const Point& hint);}
|
||||
{Returns a pair \ccc{<Point,Primitive>} which realizes the smallest distance between the query point and all input primitives. See \ccc{closest_point} function for the optional \ccc{hint} parameter. }
|
||||
{Returns a \ccc{std::pair<Point,Primitive>} which realizes the smallest distance between the query point and all input primitives. See \ccc{closest_point} function for the optional \ccc{hint} parameter. }
|
||||
|
||||
\ccMethod{FT
|
||||
squared_distance(const Point& query,
|
||||
const Point& hint);}
|
||||
{Returns the squared distance between the query point and all input primitives. See \ccc{closest_point} function for the optional \ccc{hint} parameter. }
|
||||
|
||||
{Returns the minimum squared distance between the query point and all input primitives. See \ccc{closest_point} function for the optional \ccc{hint} parameter. }
|
||||
|
||||
|
||||
\ccHeading{Accelerating the distance queries}
|
||||
|
||||
\ccMethod{void construct_search_tree();}
|
||||
{ Constructs the internal search KD-tree used to accelerate the distance queries. The points in the search tree are taken from the primitives by calling the function \ccc{point_on} from the primitive.}
|
||||
{ Constructs the internal search KD-tree used to accelerate the distance queries. The points in the search tree are taken from the primitives by calling the member function \ccc{point_on} from the primitive.}
|
||||
|
||||
\begin{ccAdvanced}
|
||||
\ccMethod{template <class ConstPointIterator>
|
||||
void construct_search_tree(ConstPointIterator begin,
|
||||
ConstPointIterator beyond);}
|
||||
{ Constructs the internal search KD-tree used to accelerate the distance queries from a specified point set. }
|
||||
{ Constructs the internal search KD-tree used to accelerate the distance queries from a specified point set. Each point from the specified point set must be located on the input primitives. For a triangle surface mesh this point set can be provided as the vertex points or as the triangle centroids.}
|
||||
\end{ccAdvanced}
|
||||
|
||||
\ccSeeAlso
|
||||
|
||||
|
|
|
|||
|
|
@ -44,17 +44,16 @@ public:
|
|||
|
||||
typedef AABB_primitive Primitive;
|
||||
typedef typename AABB_primitive::Datum Datum;
|
||||
|
||||
typedef typename GeomTraits::Sphere_3 Sphere;
|
||||
typedef typename GeomTraits::Point_3 Projection;
|
||||
|
||||
// TOFIX: Workaround for weighted_point
|
||||
#ifndef AABB_KERNEL_USE_WEIGHTED_POINT
|
||||
typedef typename GeomTraits::Point_3 Intersection;
|
||||
typedef typename GeomTraits::Point_3 Point;
|
||||
#else
|
||||
typedef typename GeomTraits::Point_3::Point Intersection;
|
||||
typedef typename GeomTraits::Point_3::Point Point;
|
||||
#endif
|
||||
|
||||
typedef typename GeomTraits::Point_3 Projection_query;
|
||||
typedef typename std::pair<typename Point, typename primitive> Point_and_primitive;
|
||||
|
||||
// types for search tree
|
||||
// TOFIX: how can we avoid repeating those?
|
||||
|
|
@ -68,7 +67,8 @@ public:
|
|||
typedef typename GeomTraits::Construct_max_vertex_3 Construct_max_vertex_3;
|
||||
typedef typename GeomTraits::Compute_squared_radius_3 Compute_squared_radius_3;
|
||||
typedef typename GeomTraits::Cartesian_const_iterator_3 Cartesian_const_iterator_3;
|
||||
typedef typename GeomTraits::Construct_cartesian_const_iterator_3 Construct_cartesian_const_iterator_3;
|
||||
typedef typename GeomTraits::Construct_cartesian_const_iterator_3
|
||||
Construct_cartesian_const_iterator_3;
|
||||
|
||||
/// Constructor
|
||||
AABB_traits() { };
|
||||
|
|
@ -126,22 +126,21 @@ public:
|
|||
template<typename Query>
|
||||
bool intersection(const Query& q,
|
||||
const Primitive& pr,
|
||||
Intersection& intersection) const;
|
||||
Point_and_primitive& result) const;
|
||||
|
||||
Sphere sphere(const Projection_query& center,
|
||||
const Projection& hint) const
|
||||
Sphere sphere(const Point& center,
|
||||
const Point& hint) const
|
||||
{
|
||||
return GeomTraits().construct_sphere_3_object()
|
||||
(center, GeomTraits().compute_squared_distance_3_object()(center, hint));
|
||||
}
|
||||
|
||||
template <typename Query>
|
||||
Projection nearest_point(const Query& q,
|
||||
Point nearest_point(const Query& q,
|
||||
const Primitive& pr,
|
||||
const Projection& bound) const
|
||||
const Point& bound) const
|
||||
{
|
||||
return CGAL::nearest_point_3(q, pr.datum(), bound);
|
||||
//return GeomTraits().nearest_point_3_object()(q, pr.datum(), bound);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
@ -214,7 +213,7 @@ template<typename Query>
|
|||
bool
|
||||
AABB_traits<GT,P>::intersection(const Query& q,
|
||||
const P& pr,
|
||||
Intersection& result) const
|
||||
Point_and_primitive& result) const
|
||||
{
|
||||
// TODO: implement a real intersection construction method
|
||||
// do_intersect is needed here because we construct intersection between
|
||||
|
|
@ -225,15 +224,15 @@ AABB_traits<GT,P>::intersection(const Query& q,
|
|||
}
|
||||
|
||||
// AABB tree package call
|
||||
// TODO: extend kernel
|
||||
Datum datum = pr.datum();
|
||||
CGAL::Object intersection_obj = CGAL::intersection(datum, q);
|
||||
|
||||
return CGAL::assign(result, intersection_obj);
|
||||
Point point;
|
||||
if(CGAL::assign(point, intersection_obj))
|
||||
result = std::pair<point,pr>;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Private methods
|
||||
//-------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -37,13 +37,14 @@ namespace CGAL {
|
|||
class AABB_tree
|
||||
{
|
||||
public:
|
||||
/// Traits types
|
||||
/// types
|
||||
typedef typename AABBTraits::FT FT;
|
||||
typedef typename AABBTraits::Point Point;
|
||||
typedef typename AABBTraits::Primitive Primitive;
|
||||
typedef typename AABBTraits::Projection Projection;
|
||||
typedef typename AABBTraits::Bounding_box Bounding_box;
|
||||
typedef typename AABBTraits::Intersection Intersection;
|
||||
typedef typename AABBTraits::Projection_query Projection_query;
|
||||
typedef typename std::pair<typename Point,typename Primitive> Point_and_primitive;
|
||||
private:
|
||||
// internal KD-tree used to accelerate the distance queries
|
||||
typedef AABB_search_tree<AABBTraits> Search_tree;
|
||||
|
||||
public:
|
||||
|
|
@ -83,7 +84,8 @@ namespace CGAL {
|
|||
template<typename ConstPointIterator>
|
||||
void construct_search_tree(ConstPointIterator first, ConstPointIterator beyond);
|
||||
|
||||
/// Construct internal search tree from a point set taken on the internal primitives
|
||||
/// Construct internal search tree from
|
||||
/// a point set taken on the internal primitives
|
||||
void construct_search_tree(void);
|
||||
|
||||
template<typename Query>
|
||||
|
|
@ -108,11 +110,15 @@ namespace CGAL {
|
|||
bool any_intersected_primitive(const Query& q,
|
||||
Primitive& pr) const;
|
||||
|
||||
Projection closest_point(const Projection_query& q,
|
||||
const Projection& hint) const;
|
||||
|
||||
// TOFIX: make it const
|
||||
Projection closest_point(const Projection_query& q);
|
||||
// distance queries
|
||||
FT squared_distance(const Point& q, const Point& hint) const;
|
||||
FT squared_distance(const Point& q) const;
|
||||
Point closest_point(const Point& q, const Point& hint) const;
|
||||
Point closest_point(const Point& q) const;
|
||||
Primitive closest_primitive(const Point& q, const Point& hint) const;
|
||||
Primitive closest_primitive(const Point& q) const;
|
||||
Point_and_primitive closest_point_and_primitive(const Point& q, const Point& hint) const;
|
||||
Point_and_primitive closest_point_and_primitive(const Point& q) const;
|
||||
|
||||
//////////////////////////////////////////////
|
||||
//TODO: document this
|
||||
|
|
@ -158,12 +164,12 @@ namespace CGAL {
|
|||
return AABBTraits().do_intersect(q, node.bounding_box());
|
||||
}
|
||||
|
||||
Intersection result() const { return m_result; }
|
||||
Point_and_primitive result() const { return m_result; }
|
||||
bool is_intersection_found() const { return m_is_found; }
|
||||
|
||||
private:
|
||||
bool m_is_found;
|
||||
Intersection m_result;
|
||||
Point_and_primitive m_result;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -175,16 +181,16 @@ namespace CGAL {
|
|||
{
|
||||
public:
|
||||
Counting_traits()
|
||||
: intersection_()
|
||||
, intersection_nb_(0) {}
|
||||
: m_intersection()
|
||||
, m_nb_intersections(0) {}
|
||||
|
||||
bool go_further() const { return true; }
|
||||
|
||||
void intersection(const Query& q, const Primitive& primitive)
|
||||
{
|
||||
if( AABBTraits().intersection(q, primitive, intersection_) )
|
||||
if( AABBTraits().intersection(q, primitive, m_intersection) )
|
||||
{
|
||||
++intersection_nb_;
|
||||
++m_nb_intersections;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -193,11 +199,11 @@ namespace CGAL {
|
|||
return AABBTraits().do_intersect(q, node.bounding_box());
|
||||
}
|
||||
|
||||
int intersection_number() const { return intersection_nb_; }
|
||||
int intersection_number() const { return m_nb_intersections; }
|
||||
|
||||
private:
|
||||
Intersection intersection_;
|
||||
int intersection_nb_;
|
||||
Point_and_primitive m_intersection;
|
||||
int m_nb_intersections;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -209,16 +215,16 @@ namespace CGAL {
|
|||
{
|
||||
public:
|
||||
Listing_intersection_traits(Output_iterator out_it)
|
||||
: intersection_()
|
||||
, out_it_(out_it) {}
|
||||
: m_intersection()
|
||||
, m_out_it(out_it) {}
|
||||
|
||||
bool go_further() const { return true; }
|
||||
|
||||
void intersection(const Query& q, const Primitive& primitive)
|
||||
{
|
||||
if( AABBTraits().intersection(q, primitive, intersection_) )
|
||||
if( AABBTraits().intersection(q, primitive, m_intersection) )
|
||||
{
|
||||
*out_it_++ = intersection_;
|
||||
*m_out_it++ = m_intersection;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -228,8 +234,8 @@ namespace CGAL {
|
|||
}
|
||||
|
||||
private:
|
||||
Intersection intersection_;
|
||||
Output_iterator out_it_;
|
||||
Intersection m_intersection;
|
||||
Output_iterator m_out_it;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -241,7 +247,7 @@ namespace CGAL {
|
|||
{
|
||||
public:
|
||||
Listing_primitive_traits(Output_iterator out_it)
|
||||
: out_it_(out_it) {}
|
||||
: m_out_it(out_it) {}
|
||||
|
||||
bool go_further() const { return true; }
|
||||
|
||||
|
|
@ -249,7 +255,7 @@ namespace CGAL {
|
|||
{
|
||||
if( AABBTraits().do_intersect(q, primitive) )
|
||||
{
|
||||
*out_it_++ = primitive;
|
||||
*m_out_it++ = primitive;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -259,38 +265,41 @@ namespace CGAL {
|
|||
}
|
||||
|
||||
private:
|
||||
Output_iterator out_it_;
|
||||
Output_iterator m_out_it;
|
||||
};
|
||||
|
||||
/**
|
||||
* @class Projection_traits
|
||||
*/
|
||||
class Projecting_traits
|
||||
class Distance_traits
|
||||
{
|
||||
public:
|
||||
Projecting_traits(const Projection_query& query,
|
||||
const Projection& hint)
|
||||
: projection_(hint)
|
||||
, sphere_(AABBTraits().sphere(query,hint)) { }
|
||||
Distance_traits(const Point& query,
|
||||
const Point& hint)
|
||||
: m_closest_point(hint),
|
||||
m_sphere(AABBTraits().sphere(query,hint))
|
||||
{}
|
||||
|
||||
bool go_further() const { return true; }
|
||||
|
||||
void intersection(const Projection_query& q, const Primitive& primitive)
|
||||
void intersection(const Point& query, const Primitive& primitive)
|
||||
{
|
||||
projection_ = AABBTraits().nearest_point(q, primitive, projection_);
|
||||
sphere_ = AABBTraits().sphere(q, projection_);
|
||||
// TOFIX: update m_closest_primitive
|
||||
m_closest_point = AABBTraits().nearest_point(query, primitive, m_closest_point);
|
||||
m_sphere = AABBTraits().sphere(q, m_closest_point);
|
||||
}
|
||||
|
||||
bool do_intersect(const Projection_query& q, const Node& node) const
|
||||
bool do_intersect(const Point& q, const Node& node) const
|
||||
{
|
||||
return AABBTraits().do_intersect(sphere_, node.bounding_box());
|
||||
return AABBTraits().do_intersect(m_sphere, node.bounding_box());
|
||||
}
|
||||
|
||||
Projection projection() const { return projection_; }
|
||||
Point closest_point() const { return m_closest_point; }
|
||||
|
||||
private:
|
||||
Projection projection_;
|
||||
Sphere sphere_;
|
||||
// TOFIX: add closest_primitive
|
||||
Sphere m_sphere;
|
||||
Point m_closest_point;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -384,7 +393,7 @@ namespace CGAL {
|
|||
void AABB_tree<Tr>::construct_search_tree(void)
|
||||
{
|
||||
// iterate over primitives to get points on them
|
||||
std::list<Projection_query> points;
|
||||
std::list<Point> points;
|
||||
typename std::vector<Primitive>::const_iterator it;
|
||||
for(it = m_data.begin(); it != m_data.end(); ++it)
|
||||
{
|
||||
|
|
@ -450,25 +459,44 @@ namespace CGAL {
|
|||
template<typename Query>
|
||||
bool
|
||||
AABB_tree<Tr>::any_intersection(const Query& query,
|
||||
Intersection& intersection) const
|
||||
Point_and_primitive& point_and_primitive) const
|
||||
{
|
||||
typedef First_intersection_traits<Query> Traversal_traits;
|
||||
Traversal_traits traversal_traits;
|
||||
|
||||
this->traversal(query, traversal_traits);
|
||||
|
||||
intersection = traversal_traits.result();
|
||||
point_and_primitive = traversal_traits.result();
|
||||
return traversal_traits.is_intersection_found();
|
||||
}
|
||||
|
||||
|
||||
// squared distance with user-specified hint
|
||||
template<typename Tr>
|
||||
typename AABB_tree<Tr>::FT
|
||||
AABB_tree<Tr>::squared_distance(const Point& query,
|
||||
const Point& hint) const
|
||||
{
|
||||
Point closest = closest_point(query, hint);
|
||||
return CGAL::squared_distance(query, closest);
|
||||
}
|
||||
|
||||
// squared distance without user-specified hint
|
||||
template<typename Tr>
|
||||
typename AABB_tree<Tr>::FT
|
||||
AABB_tree<Tr>::squared_distance(const Point& query) const
|
||||
{
|
||||
Point closest = closest_point(query);
|
||||
return CGAL::squared_distance(query, closest);
|
||||
}
|
||||
|
||||
// closest point with user-specified hint
|
||||
template<typename Tr>
|
||||
typename AABB_tree<Tr>::Projection
|
||||
AABB_tree<Tr>::closest_point(const Projection_query& query,
|
||||
const Projection& hint) const
|
||||
typename AABB_tree<Tr>::Point
|
||||
AABB_tree<Tr>::closest_point(const Point& query,
|
||||
const Point& hint) const
|
||||
{
|
||||
Projecting_traits traversal_traits(query,hint);
|
||||
|
||||
Distance_traits traversal_traits(query,hint);
|
||||
this->traversal(query, traversal_traits);
|
||||
return traversal_traits.projection();
|
||||
}
|
||||
|
|
@ -476,11 +504,11 @@ namespace CGAL {
|
|||
// closest point without hint, the search KD-tree is queried for the
|
||||
// first nearest neighbor point to get a hint
|
||||
template<typename Tr>
|
||||
typename AABB_tree<Tr>::Projection
|
||||
AABB_tree<Tr>::closest_point(const Projection_query& query)
|
||||
typename AABB_tree<Tr>::Point
|
||||
AABB_tree<Tr>::closest_point(const Point& query) const
|
||||
{
|
||||
// construct search KD-tree if needed
|
||||
Projection hint;
|
||||
Point hint;
|
||||
if(m_search_tree_constructed)
|
||||
{
|
||||
// pick nearest neighbor point as hint (fast)
|
||||
|
|
|
|||
Loading…
Reference in New Issue