mirror of https://github.com/CGAL/cgal
*** empty log message ***
This commit is contained in:
parent
74d743886a
commit
e9094e1eef
|
|
@ -29,14 +29,14 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
template <class GeomTraits>
|
||||
template <class SearchTraits>
|
||||
class Euclidean_distance {
|
||||
|
||||
public:
|
||||
|
||||
typedef typename GeomTraits::Point Point;
|
||||
typedef typename GeomTraits::NT NT;
|
||||
typedef Point Query_item;
|
||||
typedef typename SearchTraits::Point_d Point_d;
|
||||
typedef typename SearchTraits::FT FT;
|
||||
typedef Point_d Query_item;
|
||||
|
||||
public:
|
||||
|
||||
|
|
@ -44,10 +44,10 @@ namespace CGAL {
|
|||
Euclidean_distance() {}
|
||||
|
||||
|
||||
inline NT distance(const Point& q, const Point& p) const {
|
||||
NT distance = NT(0);
|
||||
typename GeomTraits::Construct_cartesian_const_iterator construct_it;
|
||||
typename GeomTraits::Cartesian_const_iterator qit = construct_it(q),
|
||||
inline FT transformed_distance(const Point_d& q, const Point_d& p) const {
|
||||
FT distance = FT(0);
|
||||
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it;
|
||||
typename SearchTraits::Cartesian_const_iterator_d qit = construct_it(q),
|
||||
qe = construct_it(q,1), pit = construct_it(p);
|
||||
for(; qit != qe; qit++, pit++){
|
||||
distance += ((*qit)-(*pit))*((*qit)-(*pit));
|
||||
|
|
@ -56,11 +56,11 @@ namespace CGAL {
|
|||
}
|
||||
|
||||
|
||||
inline NT min_distance_to_rectangle(const Point& q,
|
||||
const Kd_tree_rectangle<GeomTraits>& r) const {
|
||||
NT distance = NT(0);
|
||||
typename GeomTraits::Construct_cartesian_const_iterator construct_it;
|
||||
typename GeomTraits::Cartesian_const_iterator qit = construct_it(q),
|
||||
inline FT min_distance_to_rectangle(const Point_d& q,
|
||||
const Kd_tree_rectangle<SearchTraits>& r) const {
|
||||
FT distance = FT(0);
|
||||
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it;
|
||||
typename SearchTraits::Cartesian_const_iterator_d qit = construct_it(q),
|
||||
qe = construct_it(q,1);
|
||||
for(unsigned int i = 0;qit != qe; i++, qit++){
|
||||
if((*qit) < r.min_coord(i))
|
||||
|
|
@ -74,14 +74,14 @@ namespace CGAL {
|
|||
return distance;
|
||||
}
|
||||
|
||||
inline NT max_distance_to_rectangle(const Point& q,
|
||||
const Kd_tree_rectangle<GeomTraits>& r) const {
|
||||
NT distance=NT(0);
|
||||
typename GeomTraits::Construct_cartesian_const_iterator construct_it;
|
||||
typename GeomTraits::Cartesian_const_iterator qit = construct_it(q),
|
||||
inline FT max_distance_to_rectangle(const Point_d& q,
|
||||
const Kd_tree_rectangle<SearchTraits>& r) const {
|
||||
FT distance=FT(0);
|
||||
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it;
|
||||
typename SearchTraits::Cartesian_const_iterator_d qit = construct_it(q),
|
||||
qe = construct_it(q,1);
|
||||
for(unsigned int i = 0;qit != qe; i++, qit++){
|
||||
if ((*qit) <= (r.min_coord(i)+r.max_coord(i))/NT(2.0))
|
||||
if ((*qit) <= (r.min_coord(i)+r.max_coord(i))/FT(2.0))
|
||||
distance += (r.max_coord(i)-(*qit))*(r.max_coord(i)-(*qit));
|
||||
else
|
||||
distance += ((*qit)-r.min_coord(i))*((*qit)-r.min_coord(i));
|
||||
|
|
@ -89,18 +89,18 @@ namespace CGAL {
|
|||
return distance;
|
||||
}
|
||||
|
||||
inline NT new_distance(NT dist, NT old_off, NT new_off,
|
||||
inline FT new_distance(FT dist, FT old_off, FT new_off,
|
||||
int cutting_dimension) const {
|
||||
|
||||
NT new_dist = dist + new_off*new_off - old_off*old_off;
|
||||
FT new_dist = dist + new_off*new_off - old_off*old_off;
|
||||
return new_dist;
|
||||
}
|
||||
|
||||
inline NT transformed_distance(NT d) const {
|
||||
inline FT transformed_distance(FT d) const {
|
||||
return d*d;
|
||||
}
|
||||
|
||||
inline NT inverse_of_transformed_distance(NT d) const {
|
||||
inline FT inverse_of_transformed_distance(FT d) const {
|
||||
return CGAL::sqrt(d);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,13 +29,13 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
template <class GeomTraits, class Sphere>
|
||||
template <class SearchTraits, class Sphere>
|
||||
class Euclidean_distance_sphere_point {
|
||||
|
||||
public:
|
||||
|
||||
typedef typename GeomTraits::Point Point;
|
||||
typedef typename GeomTraits::NT NT;
|
||||
typedef typename SearchTraits::Point_d Point_d;
|
||||
typedef typename SearchTraits::FT FT;
|
||||
typedef Sphere Query_item;
|
||||
public:
|
||||
|
||||
|
|
@ -43,27 +43,27 @@ namespace CGAL {
|
|||
Euclidean_distance_sphere_point() {}
|
||||
|
||||
|
||||
inline NT distance(const Sphere& q, const Point& p) const {
|
||||
Point c=q.center();
|
||||
NT distance = NT(0);
|
||||
typename GeomTraits::Construct_cartesian_const_iterator construct_it;
|
||||
typename GeomTraits::Cartesian_const_iterator cit = construct_it(c),
|
||||
inline FT transformed_distance(const Sphere& q, const Point_d& p) const {
|
||||
Point_d c=q.center();
|
||||
FT distance = FT(0);
|
||||
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it;
|
||||
typename SearchTraits::Cartesian_const_iterator_d cit = construct_it(c),
|
||||
ce = construct_it(c,1), pit = construct_it(p);
|
||||
for(; cit != ce; cit++, pit++){
|
||||
distance += ((*cit)-(*pit))*((*cit)-(*pit));
|
||||
}
|
||||
distance += -q.squared_radius();
|
||||
if (distance<0) distance=NT(0);
|
||||
if (distance<0) distance=FT(0);
|
||||
return distance;
|
||||
}
|
||||
|
||||
|
||||
inline NT min_distance_to_rectangle(const Sphere& q,
|
||||
const Kd_tree_rectangle<GeomTraits>& r) const {
|
||||
Point c=q.center();
|
||||
NT distance = NT(0);
|
||||
typename GeomTraits::Construct_cartesian_const_iterator construct_it;
|
||||
typename GeomTraits::Cartesian_const_iterator cit = construct_it(c),
|
||||
inline FT min_distance_to_rectangle(const Sphere& q,
|
||||
const Kd_tree_rectangle<SearchTraits>& r) const {
|
||||
Point_d c=q.center();
|
||||
FT distance = FT(0);
|
||||
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it;
|
||||
typename SearchTraits::Cartesian_const_iterator_d cit = construct_it(c),
|
||||
ce = construct_it(c,1);
|
||||
for (unsigned int i = 0; cit != ce; ++i, ++cit) {
|
||||
if ((*cit) < r.min_coord(i))
|
||||
|
|
@ -75,35 +75,35 @@ namespace CGAL {
|
|||
|
||||
};
|
||||
distance += -q.squared_radius();
|
||||
if (distance<0) distance=NT(0);
|
||||
if (distance<0) distance=FT(0);
|
||||
return distance;
|
||||
}
|
||||
|
||||
inline NT max_distance_to_rectangle(const Sphere& q,
|
||||
const Kd_tree_rectangle<GeomTraits>& r) const {
|
||||
Point c=q.center();
|
||||
NT distance=NT(0);
|
||||
typename GeomTraits::Construct_cartesian_const_iterator construct_it;
|
||||
typename GeomTraits::Cartesian_const_iterator cit = construct_it(c),
|
||||
inline FT max_distance_to_rectangle(const Sphere& q,
|
||||
const Kd_tree_rectangle<SearchTraits>& r) const {
|
||||
Point_d c=q.center();
|
||||
FT distance=FT(0);
|
||||
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it;
|
||||
typename SearchTraits::Cartesian_const_iterator_d cit = construct_it(c),
|
||||
ce = construct_it(c,1);
|
||||
for (unsigned int i = 0; cit != ce; ++i, ++cit) {
|
||||
if ((*cit) <= (r.min_coord(i)+r.max_coord(i))/NT(2.0))
|
||||
if ((*cit) <= (r.min_coord(i)+r.max_coord(i))/FT(2.0))
|
||||
distance += (r.max_coord(i)-(*cit))*(r.max_coord(i)-(*cit));
|
||||
else
|
||||
distance += ((*cit)-r.min_coord(i))*((*cit)-r.min_coord(i));
|
||||
};
|
||||
distance += -q.squared_radius();
|
||||
if (distance<0) distance=NT(0);
|
||||
if (distance<0) distance=FT(0);
|
||||
return distance;
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline NT transformed_distance(NT d) const {
|
||||
inline FT transformed_distance(FT d) const {
|
||||
return d*d;
|
||||
}
|
||||
|
||||
inline NT inverse_of_transformed_distance(NT d) const {
|
||||
inline FT inverse_of_transformed_distance(FT d) const {
|
||||
return CGAL::sqrt(d);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,18 +29,18 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
template <class GeomTraits, class Iso_box>
|
||||
template <class SearchTraits, class Iso_box>
|
||||
class Fuzzy_iso_box{
|
||||
|
||||
public:
|
||||
|
||||
typedef typename GeomTraits::Point Point;
|
||||
typedef typename GeomTraits::NT NT;
|
||||
typedef typename SearchTraits::Point_d Point_d;
|
||||
typedef typename SearchTraits::FT FT;
|
||||
|
||||
private:
|
||||
|
||||
Iso_box box;
|
||||
NT eps;
|
||||
FT eps;
|
||||
unsigned int dim;
|
||||
|
||||
public:
|
||||
|
|
@ -49,27 +49,27 @@ namespace CGAL {
|
|||
Fuzzy_iso_box() {}
|
||||
|
||||
// constructor
|
||||
Fuzzy_iso_box(const Point& p, const Point& q, NT epsilon=NT(0))
|
||||
Fuzzy_iso_box(const Point_d& p, const Point_d& q, FT epsilon=FT(0))
|
||||
: eps(epsilon)
|
||||
{
|
||||
typename GeomTraits::Construct_cartesian_const_iterator construct_it;
|
||||
typename GeomTraits::Cartesian_const_iterator begin = construct_it(p),
|
||||
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it;
|
||||
typename SearchTraits::Cartesian_const_iterator_d begin = construct_it(p),
|
||||
end = construct_it(p,1);
|
||||
dim = end - begin;
|
||||
box = Iso_box(p,q);
|
||||
}
|
||||
|
||||
|
||||
bool contains(const Point& p) const {
|
||||
typename GeomTraits::Construct_cartesian_const_iterator construct_it;
|
||||
typename GeomTraits::Cartesian_const_iterator pit = construct_it(p);
|
||||
bool contains(const Point_d& p) const {
|
||||
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it;
|
||||
typename SearchTraits::Cartesian_const_iterator_d pit = construct_it(p);
|
||||
for (unsigned int i = 0; i < dim; ++i, ++pit) {
|
||||
if ( ((*pit) < box.min()[i]) || ((*pit) >= box.max()[i]) ) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool inner_range_intersects(const Kd_tree_rectangle<GeomTraits>& rectangle) const {
|
||||
bool inner_range_intersects(const Kd_tree_rectangle<SearchTraits>& rectangle) const {
|
||||
for (unsigned int i = 0; i < dim; ++i) {
|
||||
if ( (box.max()[i]-eps < rectangle.min_coord(i))
|
||||
|| (box.min()[i]+eps >= rectangle.max_coord(i)) ) return false;
|
||||
|
|
@ -78,7 +78,7 @@ namespace CGAL {
|
|||
}
|
||||
|
||||
|
||||
bool outer_range_is_contained_by(const Kd_tree_rectangle<GeomTraits>& rectangle) const {
|
||||
bool outer_range_is_contained_by(const Kd_tree_rectangle<SearchTraits>& rectangle) const {
|
||||
for (unsigned int i = 0; i < dim; ++i) {
|
||||
if ( (box.max()[i]+eps < rectangle.max_coord(i) )
|
||||
|| (box.min()[i]-eps >= rectangle.min_coord(i)) ) return false;
|
||||
|
|
|
|||
|
|
@ -29,19 +29,19 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
template <class PointTraits>
|
||||
template <class SearchTraits>
|
||||
class Fuzzy_sphere{
|
||||
|
||||
public:
|
||||
|
||||
typedef typename PointTraits::NT NT;
|
||||
typedef typename SearchTraits::FT FT;
|
||||
|
||||
typedef typename PointTraits::Point Point;
|
||||
typedef typename SearchTraits::Point_d Point_d;
|
||||
private:
|
||||
|
||||
Point c;
|
||||
NT r;
|
||||
NT eps;
|
||||
Point_d c;
|
||||
FT r;
|
||||
FT eps;
|
||||
unsigned int dim;
|
||||
|
||||
public:
|
||||
|
|
@ -51,18 +51,18 @@ namespace CGAL {
|
|||
|
||||
|
||||
// constructor
|
||||
Fuzzy_sphere(const Point& center, NT radius, NT epsilon=NT(0)) :
|
||||
Fuzzy_sphere(const Point_d& center, FT radius, FT epsilon=FT(0)) :
|
||||
c(center), r(radius), eps(epsilon), dim(c.dimension())
|
||||
{ // avoid problems if eps > r
|
||||
if (eps>r) eps=r;
|
||||
}
|
||||
|
||||
bool contains(const Point& p) const {
|
||||
bool contains(const Point_d& p) const {
|
||||
// test whether the squared distance
|
||||
// between P and c
|
||||
// is at most the squared_radius
|
||||
NT squared_radius = r*r;
|
||||
NT distance=NT(0);
|
||||
FT squared_radius = r*r;
|
||||
FT distance=FT(0);
|
||||
for (unsigned int i = 0;
|
||||
(i < dim) && (distance <= squared_radius); ++i) {
|
||||
distance +=
|
||||
|
|
@ -72,12 +72,12 @@ namespace CGAL {
|
|||
}
|
||||
|
||||
|
||||
bool inner_range_intersects(const Kd_tree_rectangle<PointTraits>& rectangle) const {
|
||||
bool inner_range_intersects(const Kd_tree_rectangle<SearchTraits>& rectangle) const {
|
||||
// test whether the interior of a sphere
|
||||
// with radius (r-eps) intersects r, i.e.
|
||||
// if the minimal distance of r to c is less than r-eps
|
||||
NT distance = NT(0);
|
||||
NT squared_radius = (r-eps)*(r-eps);
|
||||
FT distance = FT(0);
|
||||
FT squared_radius = (r-eps)*(r-eps);
|
||||
for (unsigned int i = 0; (i < dim) && (distance < squared_radius); ++i) {
|
||||
if (c[i] < rectangle.min_coord(i))
|
||||
distance +=
|
||||
|
|
@ -90,15 +90,15 @@ namespace CGAL {
|
|||
}
|
||||
|
||||
|
||||
bool outer_range_is_contained_by(const Kd_tree_rectangle<PointTraits>& rectangle) const {
|
||||
bool outer_range_is_contained_by(const Kd_tree_rectangle<SearchTraits>& rectangle) const {
|
||||
// test whether the interior of a sphere
|
||||
// with radius (r+eps) is contained by r, i.e.
|
||||
// if the minimal distance of the boundary of r
|
||||
// to c is less than r+eps
|
||||
NT distance=NT(0);
|
||||
NT squared_radius = (r+eps)*(r+eps);
|
||||
FT distance=FT(0);
|
||||
FT squared_radius = (r+eps)*(r+eps);
|
||||
for (unsigned int i = 0; (i < dim) && (distance < squared_radius) ; ++i) {
|
||||
if (c[i] <= (rectangle.min_coord(i)+rectangle.max_coord(i))/NT(2))
|
||||
if (c[i] <= (rectangle.min_coord(i)+rectangle.max_coord(i))/FT(2))
|
||||
distance +=
|
||||
(rectangle.max_coord(i)-c[i])*(rectangle.max_coord(i)-c[i]);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -34,22 +34,22 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
template <class GeomTraits,
|
||||
class Distance_=Euclidean_distance<GeomTraits>,
|
||||
class Splitter_ = Sliding_midpoint<GeomTraits>,
|
||||
class Tree_=Kd_tree<GeomTraits, Splitter_, Tag_false> >
|
||||
template <class SearchTraits,
|
||||
class Distance_=Euclidean_distance<SearchTraits>,
|
||||
class Splitter_ = Sliding_midpoint<SearchTraits>,
|
||||
class Tree_=Kd_tree<SearchTraits, Splitter_, Tag_false> >
|
||||
class Incremental_neighbor_search {
|
||||
|
||||
public:
|
||||
|
||||
typedef Distance_ Distance;
|
||||
typedef Tree_ Tree;
|
||||
typedef typename GeomTraits::Point Point;
|
||||
typedef typename GeomTraits::NT NT;
|
||||
typedef typename Tree::Point_iterator Point_iterator;
|
||||
typedef typename SearchTraits::Point_d Point_d;
|
||||
typedef typename SearchTraits::FT FT;
|
||||
typedef typename Tree::Point_d_iterator Point_d_iterator;
|
||||
typedef typename Tree::Node_handle Node_handle;
|
||||
typedef typename Tree::Splitter Splitter;
|
||||
typedef Kd_tree_rectangle<GeomTraits> Node_box;
|
||||
typedef Kd_tree_rectangle<SearchTraits> Node_box;
|
||||
typedef typename Distance::Query_item Query_item;
|
||||
|
||||
class Cell
|
||||
|
|
@ -78,8 +78,8 @@ class Cell
|
|||
|
||||
|
||||
|
||||
typedef std::pair<Point,NT> Point_with_distance;
|
||||
typedef std::pair<Cell*,NT> Cell_with_distance;
|
||||
typedef std::pair<Point_d,FT> Point_with_distance;
|
||||
typedef std::pair<Cell*,FT> Cell_with_distance;
|
||||
|
||||
// this forward declaration may problems for g++
|
||||
class iterator;
|
||||
|
|
@ -89,7 +89,7 @@ class iterator;
|
|||
|
||||
typedef std::vector<Point_with_distance*> Point_with_distance_vector;
|
||||
|
||||
typedef std::vector<NT> Distance_vector;
|
||||
typedef std::vector<FT> Distance_vector;
|
||||
|
||||
iterator *start;
|
||||
iterator *past_the_end;
|
||||
|
|
@ -98,7 +98,7 @@ class iterator;
|
|||
|
||||
// constructor
|
||||
Incremental_neighbor_search(Tree& tree, const Query_item& q,
|
||||
NT Eps=NT(0.0), bool search_nearest=true,
|
||||
FT Eps=FT(0.0), bool search_nearest=true,
|
||||
const Distance& tr=Distance())
|
||||
{
|
||||
start = new iterator(tree,q,tr,Eps,search_nearest);
|
||||
|
|
@ -145,7 +145,7 @@ class iterator;
|
|||
}
|
||||
|
||||
// constructor
|
||||
iterator(const Tree& tree, const Query_item& q, const Distance& tr, NT eps,
|
||||
iterator(const Tree& tree, const Query_item& q, const Distance& tr, FT eps,
|
||||
bool search_nearest) {
|
||||
Ptr_implementation =
|
||||
new Iterator_implementation(tree, q, tr, eps, search_nearest);
|
||||
|
|
@ -210,17 +210,17 @@ class iterator;
|
|||
|
||||
private:
|
||||
|
||||
NT multiplication_factor;
|
||||
FT multiplication_factor;
|
||||
|
||||
Query_item query_point;
|
||||
|
||||
int total_item_number;
|
||||
|
||||
NT distance_to_root;
|
||||
FT distance_to_root;
|
||||
|
||||
bool search_nearest_neighbour;
|
||||
|
||||
NT rd;
|
||||
FT rd;
|
||||
|
||||
class Priority_higher
|
||||
{
|
||||
|
|
@ -280,7 +280,7 @@ class Distance_smaller
|
|||
|
||||
// constructor
|
||||
Iterator_implementation(const Tree& tree, const Query_item& q,const Distance& tr,
|
||||
NT Eps, bool search_nearest)
|
||||
FT Eps, bool search_nearest)
|
||||
{
|
||||
|
||||
|
||||
|
|
@ -296,7 +296,7 @@ class Distance_smaller
|
|||
reference_count=1;
|
||||
Distance_instance=new Distance(tr);
|
||||
multiplication_factor=
|
||||
Distance_instance->transformed_distance(NT(1)+Eps);
|
||||
Distance_instance->transformed_distance(FT(1)+Eps);
|
||||
|
||||
Node_box *bounding_box = new Node_box(*(tree.bounding_box()));
|
||||
|
||||
|
|
@ -422,16 +422,16 @@ class Distance_smaller
|
|||
while (!(N->is_leaf())) { // compute new distances
|
||||
number_of_internal_nodes_visited++;
|
||||
int new_cut_dim=N->cutting_dimension();
|
||||
NT new_cut_val=N->cutting_value();
|
||||
FT new_cut_val=N->cutting_value();
|
||||
|
||||
Node_box* lower_box = new Node_box(*B);
|
||||
Node_box* upper_box =
|
||||
lower_box->split(new_cut_dim, new_cut_val);
|
||||
delete B;
|
||||
if (search_nearest_neighbour) {
|
||||
NT distance_to_box_lower =
|
||||
FT distance_to_box_lower =
|
||||
Distance_instance->min_distance_to_rectangle(query_point, *lower_box);
|
||||
NT distance_to_box_upper =
|
||||
FT distance_to_box_upper =
|
||||
Distance_instance->min_distance_to_rectangle(query_point, *upper_box);
|
||||
if (distance_to_box_lower <= distance_to_box_upper) {
|
||||
Cell* C_upper = new Cell(upper_box, N->upper());
|
||||
|
|
@ -451,9 +451,9 @@ else {
|
|||
}
|
||||
}
|
||||
else { // search furthest
|
||||
NT distance_to_box_lower =
|
||||
FT distance_to_box_lower =
|
||||
Distance_instance->max_distance_to_rectangle(query_point, *lower_box);
|
||||
NT distance_to_box_upper =
|
||||
FT distance_to_box_upper =
|
||||
Distance_instance->max_distance_to_rectangle(query_point, *upper_box);
|
||||
if (distance_to_box_lower >= distance_to_box_upper) {
|
||||
Cell* C_upper = new Cell(upper_box, N->upper());
|
||||
|
|
@ -479,7 +479,7 @@ else {
|
|||
if (N->size() > 0) {
|
||||
for (Point_iterator it=N->begin(); it != N->end(); it++) {
|
||||
number_of_items_visited++;
|
||||
NT distance_to_query_point=
|
||||
FT distance_to_query_point=
|
||||
Distance_instance->
|
||||
distance(query_point,**it);
|
||||
Point_with_distance *NN_Candidate=
|
||||
|
|
|
|||
|
|
@ -28,22 +28,22 @@ namespace CGAL {
|
|||
|
||||
template <class R> class Iso_rectangle_d {
|
||||
public:
|
||||
typedef typename R::FT NT;
|
||||
typedef typename R::FT FT;
|
||||
typedef typename R::Point_d Point_d;
|
||||
|
||||
private:
|
||||
|
||||
int dim;
|
||||
NT *lower;
|
||||
NT *upper;
|
||||
FT *lower;
|
||||
FT *upper;
|
||||
|
||||
public:
|
||||
|
||||
Iso_rectangle_d(const Point_d& p, const Point_d& q)
|
||||
{ assert(p.dimension() == q.dimension());
|
||||
dim = p.dimension();
|
||||
lower = new NT[dim];
|
||||
upper = new NT[dim];
|
||||
lower = new FT[dim];
|
||||
upper = new FT[dim];
|
||||
for (int i = 0; i < dim; ++i) {
|
||||
if (p[i] <= q[i]) {
|
||||
lower[i]=p[i];
|
||||
|
|
@ -58,8 +58,8 @@ namespace CGAL {
|
|||
|
||||
// copy constructor
|
||||
Iso_rectangle_d(const Iso_rectangle_d& b) : dim(b.dim) {
|
||||
lower = new NT[dim];
|
||||
upper = new NT[dim];
|
||||
lower = new FT[dim];
|
||||
upper = new FT[dim];
|
||||
for (int i = 0; i < dim; ++i) {
|
||||
lower[i]=b.lower[i];
|
||||
upper[i]=b.upper[i];
|
||||
|
|
@ -69,7 +69,7 @@ namespace CGAL {
|
|||
|
||||
bool has_on_bounded_side(const Point_d& p) const
|
||||
{
|
||||
NT h;
|
||||
FT h;
|
||||
for (int i = 0; i < dimension(); ++i) {
|
||||
h=p[i];
|
||||
if ( (h < lower[i]) || (h > upper[i]) ) return 0;
|
||||
|
|
@ -79,11 +79,11 @@ namespace CGAL {
|
|||
|
||||
inline int dimension() const { return dim;}
|
||||
|
||||
inline NT min_coord(int i) const {
|
||||
inline FT min_coord(int i) const {
|
||||
return lower[i];
|
||||
}
|
||||
|
||||
inline NT max_coord(int i) const {
|
||||
inline FT max_coord(int i) const {
|
||||
return upper[i];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
template <class GeomTraits,
|
||||
class Distance_=Euclidean_distance<GeomTraits>,
|
||||
class Splitter_=Sliding_midpoint<GeomTraits> ,
|
||||
class Tree_=Kd_tree<GeomTraits, Splitter_, Tag_false> >
|
||||
template <class SearchTraits,
|
||||
class Distance_=Euclidean_distance<SearchTraits>,
|
||||
class Splitter_=Sliding_midpoint<SearchTraits> ,
|
||||
class Tree_=Kd_tree<SearchTraits, Splitter_, Tag_false> >
|
||||
|
||||
class K_neighbor_search {
|
||||
|
||||
|
|
@ -45,14 +45,14 @@ public:
|
|||
typedef Splitter_ Splitter;
|
||||
typedef Distance_ Distance;
|
||||
typedef Tree_ Tree;
|
||||
typedef typename GeomTraits::Point Point;
|
||||
typedef typename GeomTraits::NT NT;
|
||||
typedef std::pair<Point,NT> Point_with_distance;
|
||||
typedef typename SearchTraits::Point_d Point_d;
|
||||
typedef typename SearchTraits::FT FT;
|
||||
typedef std::pair<Point_d,FT> Point_with_distance;
|
||||
|
||||
typedef typename Tree::Node_handle Node_handle;
|
||||
|
||||
typedef typename Tree::Point_iterator Point_iterator;
|
||||
typedef Kd_tree_rectangle<GeomTraits> Rectangle;
|
||||
typedef typename Tree::Point_d_iterator Point_d_iterator;
|
||||
typedef Kd_tree_rectangle<SearchTraits> Rectangle;
|
||||
typedef typename Distance::Query_item Query_item;
|
||||
private:
|
||||
|
||||
|
|
@ -62,20 +62,24 @@ private:
|
|||
|
||||
bool search_nearest;
|
||||
|
||||
NT multiplication_factor;
|
||||
FT multiplication_factor;
|
||||
Query_item query_object;
|
||||
int total_item_number;
|
||||
NT distance_to_root;
|
||||
FT distance_to_root;
|
||||
|
||||
typedef std::list<Point_with_distance> NN_list;
|
||||
|
||||
public:
|
||||
typedef typename NN_list::const_iterator iterator;
|
||||
private:
|
||||
|
||||
NN_list l;
|
||||
int max_k;
|
||||
int actual_k;
|
||||
|
||||
Distance* distance_instance;
|
||||
|
||||
inline bool branch(NT distance) {
|
||||
inline bool branch(FT distance) {
|
||||
if (actual_k<max_k) return true;
|
||||
else
|
||||
if (search_nearest) return
|
||||
|
|
@ -85,7 +89,7 @@ private:
|
|||
|
||||
};
|
||||
|
||||
inline void insert(Point* I, NT dist) {
|
||||
inline void insert(Point_d* I, FT dist) {
|
||||
bool insert;
|
||||
if (actual_k<max_k) insert=true;
|
||||
else
|
||||
|
|
@ -110,7 +114,7 @@ private:
|
|||
|
||||
|
||||
public:
|
||||
|
||||
/*
|
||||
template<class OutputIterator>
|
||||
OutputIterator the_k_neighbors(OutputIterator res)
|
||||
{
|
||||
|
|
@ -118,18 +122,28 @@ public:
|
|||
for (; it != l.end(); it++) { *res= *it; res++; }
|
||||
return res;
|
||||
}
|
||||
*/
|
||||
|
||||
iterator begin() const
|
||||
{
|
||||
return l.begin();
|
||||
}
|
||||
|
||||
iterator end() const
|
||||
{
|
||||
return l.end();
|
||||
}
|
||||
|
||||
// constructor
|
||||
K_neighbor_search(Tree& tree, const Query_item& q,
|
||||
int k=1, NT Eps=NT(0.0),
|
||||
int k=1, FT Eps=FT(0.0),
|
||||
bool Search_nearest=true,
|
||||
const Distance& d=Distance()) {
|
||||
|
||||
distance_instance=new Distance(d);
|
||||
|
||||
multiplication_factor=
|
||||
distance_instance->transformed_distance(NT(1.0)+Eps);
|
||||
distance_instance->transformed_distance(FT(1.0)+Eps);
|
||||
|
||||
max_k=k;
|
||||
actual_k=0;
|
||||
|
|
@ -170,21 +184,21 @@ public:
|
|||
private:
|
||||
|
||||
|
||||
void compute_neighbors_general(Node_handle N, const Kd_tree_rectangle<GeomTraits>& r) {
|
||||
void compute_neighbors_general(Node_handle N, const Kd_tree_rectangle<SearchTraits>& r) {
|
||||
|
||||
if (!(N->is_leaf())) {
|
||||
number_of_internal_nodes_visited++;
|
||||
int new_cut_dim=N->cutting_dimension();
|
||||
NT new_cut_val=N->cutting_value();
|
||||
FT new_cut_val=N->cutting_value();
|
||||
|
||||
Kd_tree_rectangle<GeomTraits> r_lower(r);
|
||||
Kd_tree_rectangle<SearchTraits> r_lower(r);
|
||||
|
||||
// modifies also r_lower to lower half
|
||||
Kd_tree_rectangle<GeomTraits> r_upper(r_lower);
|
||||
Kd_tree_rectangle<SearchTraits> r_upper(r_lower);
|
||||
r_lower.split(r_upper, new_cut_dim, new_cut_val);
|
||||
|
||||
NT distance_to_lower_half;
|
||||
NT distance_to_upper_half;
|
||||
FT distance_to_lower_half;
|
||||
FT distance_to_upper_half;
|
||||
|
||||
if (search_nearest) {
|
||||
|
||||
|
|
@ -240,11 +254,11 @@ public:
|
|||
// n is a leaf
|
||||
number_of_leaf_nodes_visited++;
|
||||
if (N->size() > 0)
|
||||
for (Point_iterator it=N->begin(); it != N->end(); it++) {
|
||||
for (Point_d_iterator it=N->begin(); it != N->end(); it++) {
|
||||
number_of_items_visited++;
|
||||
NT distance_to_query_object=
|
||||
FT distance_to_query_object=
|
||||
distance_instance->
|
||||
distance(query_object,**it);
|
||||
transformed_distance(query_object,**it);
|
||||
insert(*it,distance_to_query_object);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,21 +36,21 @@
|
|||
namespace CGAL {
|
||||
|
||||
|
||||
template <class GeomTraits, class Splitter_=Sliding_midpoint<GeomTraits>, class UseExtendedNode = Tag_true >
|
||||
template <class SearchTraits, class Splitter_=Sliding_midpoint<SearchTraits>, class UseExtendedNode = Tag_true >
|
||||
class Kd_tree {
|
||||
|
||||
public:
|
||||
|
||||
typedef Splitter_ Splitter;
|
||||
typedef typename GeomTraits::Point Point;
|
||||
typedef typename SearchTraits::Point_d Point_d;
|
||||
typedef typename Splitter::Container Point_container;
|
||||
|
||||
typedef typename GeomTraits::NT NT;
|
||||
typedef Kd_tree_node<GeomTraits, Splitter, UseExtendedNode > Node;
|
||||
typedef Kd_tree<GeomTraits, Splitter> Tree;
|
||||
typedef typename SearchTraits::FT FT;
|
||||
typedef Kd_tree_node<SearchTraits, Splitter, UseExtendedNode > Node;
|
||||
typedef Kd_tree<SearchTraits, Splitter> Tree;
|
||||
|
||||
typedef typename Compact_container<Node>::iterator Node_handle;
|
||||
typedef typename std::vector<Point*>::iterator Point_iterator;
|
||||
typedef typename std::vector<Point_d*>::iterator Point_d_iterator;
|
||||
typedef typename Splitter::Separator Separator;
|
||||
|
||||
private:
|
||||
|
|
@ -60,16 +60,16 @@ private:
|
|||
|
||||
Node_handle tree_root;
|
||||
|
||||
Kd_tree_rectangle<GeomTraits>* bbox;
|
||||
std::list<Point> pts;
|
||||
Kd_tree_rectangle<SearchTraits>* bbox;
|
||||
std::list<Point_d> pts;
|
||||
|
||||
// Instead of storing the points in arrays in the Kd_tree_node
|
||||
// we put all the data in a vector in the Kd_tree.
|
||||
// and we only store an iterator range in the Kd_tree_node.
|
||||
//
|
||||
std::vector<Point*> data;
|
||||
Point_iterator data_iterator;
|
||||
GeomTraits tr;
|
||||
std::vector<Point_d*> data;
|
||||
Point_d_iterator data_iterator;
|
||||
SearchTraits tr;
|
||||
int the_item_number;
|
||||
|
||||
// protected copy constructor
|
||||
|
|
@ -200,16 +200,16 @@ template <class InputIterator>
|
|||
Splitter s = Splitter()) : split(s) {
|
||||
assert(first != beyond);
|
||||
std::copy(first, beyond, std::back_inserter(pts));
|
||||
const Point& p = *pts.begin();
|
||||
typename GeomTraits::Construct_cartesian_const_iterator ccci;
|
||||
const Point_d& p = *pts.begin();
|
||||
typename SearchTraits::Construct_cartesian_const_iterator_d ccci;
|
||||
int dim = std::distance(ccci(p), ccci(p,0));
|
||||
|
||||
data = std::vector<Point*>(pts.size()); // guarantees that iterators we store in Kd_tree_nodes stay valid
|
||||
data = std::vector<Point_d*>(pts.size()); // guarantees that iterators we store in Kd_tree_nodes stay valid
|
||||
data_iterator = data.begin();
|
||||
|
||||
Point_container c(dim, pts.begin(), pts.end());
|
||||
|
||||
bbox = new Kd_tree_rectangle<GeomTraits>(c.bounding_box());
|
||||
bbox = new Kd_tree_rectangle<SearchTraits>(c.bounding_box());
|
||||
|
||||
the_item_number=c.size();
|
||||
if (c.size() <= split.bucket_size())
|
||||
|
|
@ -223,7 +223,7 @@ template <class InputIterator>
|
|||
|
||||
template <class OutputIterator, class FuzzyQueryItem>
|
||||
OutputIterator search(OutputIterator it, const FuzzyQueryItem& q) {
|
||||
Kd_tree_rectangle<GeomTraits> b(*bbox);
|
||||
Kd_tree_rectangle<SearchTraits> b(*bbox);
|
||||
tree_root->search(it,q,b);
|
||||
return it;
|
||||
}
|
||||
|
|
@ -238,11 +238,11 @@ template <class InputIterator>
|
|||
};
|
||||
|
||||
|
||||
GeomTraits traits() const {return tr;} // Returns the traits class;
|
||||
SearchTraits traits() const {return tr;} // Returns the traits class;
|
||||
|
||||
Node_handle root()const { return tree_root; }
|
||||
|
||||
const Kd_tree_rectangle<GeomTraits>& bounding_box() const {return *bbox; }
|
||||
const Kd_tree_rectangle<SearchTraits>& bounding_box() const {return *bbox; }
|
||||
|
||||
int size() const {return the_item_number;}
|
||||
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ namespace CGAL {
|
|||
template <class Point,
|
||||
class Splitter=Sliding_midpoint<Point> >
|
||||
class Kdtree_interface_2d :
|
||||
public Kd_tree_traits_point<Point,Splitter> {
|
||||
public Search_traits<Point,Splitter> {
|
||||
|
||||
public:
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ namespace CGAL {
|
|||
Kdtree_interface_2d(unsigned int bucket_size=100,
|
||||
NT aspect_ratio=NT(3),
|
||||
bool use_extended_nodes=true) {
|
||||
Kd_tree_traits_point<Point>(bucket_size,aspect_ratio,use_extended_nodes);
|
||||
Search_traits<Point>(bucket_size,aspect_ratio,use_extended_nodes);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ namespace CGAL {
|
|||
template <class Point,
|
||||
class Splitter=Sliding_midpoint<Point> >
|
||||
class Kdtree_interface_3d :
|
||||
public Kd_tree_traits_point<Point,Splitter> {
|
||||
public Search_traits<Point,Splitter> {
|
||||
|
||||
public:
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ template <class Point,
|
|||
Kdtree_interface_3d(unsigned int bucket_size=100,
|
||||
NT aspect_ratio=NT(3),
|
||||
bool use_extended_nodes=true) {
|
||||
Kd_tree_traits_point<Point>(bucket_size,aspect_ratio,use_extended_nodes);
|
||||
Search_traits<Point>(bucket_size,aspect_ratio,use_extended_nodes);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -190,7 +190,7 @@ template <class Point,
|
|||
template <class Point,
|
||||
class Splitter=Sliding_midpoint<Point> >
|
||||
class Kdtree_interface :
|
||||
public Kd_tree_traits_point<Point,Splitter> {
|
||||
public Search_traits<Point,Splitter> {
|
||||
|
||||
public:
|
||||
|
||||
|
|
@ -232,7 +232,7 @@ template <class Point,
|
|||
Kdtree_interface(unsigned int bucket_size=100,
|
||||
NT aspect_ratio=NT(3),
|
||||
bool use_extended_nodes=true) {
|
||||
Kd_tree_traits_point<Point>(bucket_size,aspect_ratio,use_extended_nodes);
|
||||
Search_traits<Point>(bucket_size,aspect_ratio,use_extended_nodes);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
#include <CGAL/Compact_container.h>
|
||||
namespace CGAL {
|
||||
|
||||
template <class GeomTraits, class Splitter=Sliding_midpoint<GeomTraits>, class UseExtendedNode = Tag_true >
|
||||
template <class SearchTraits, class Splitter=Sliding_midpoint<SearchTraits>, class UseExtendedNode = Tag_true >
|
||||
class Kd_tree;
|
||||
|
||||
template < class TreeTraits, class Splitter, class UseExtendedNode >
|
||||
|
|
@ -35,11 +35,11 @@ namespace CGAL {
|
|||
|
||||
typedef typename Kd_tree<TreeTraits,Splitter,UseExtendedNode>::Node_handle Node_handle;
|
||||
enum Node_type {LEAF, INTERNAL, EXTENDED_INTERNAL};
|
||||
typedef typename TreeTraits::Point Point;
|
||||
typedef typename TreeTraits::Point_d Point_d;
|
||||
|
||||
typedef typename TreeTraits::NT NT;
|
||||
typedef typename TreeTraits::FT FT;
|
||||
typedef typename Kd_tree<TreeTraits>::Separator Separator;
|
||||
typedef typename Kd_tree<TreeTraits>::Point_iterator Point_iterator;
|
||||
typedef typename Kd_tree<TreeTraits>::Point_d_iterator Point_d_iterator;
|
||||
|
||||
private:
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ namespace CGAL {
|
|||
|
||||
// private variables for leaf nodes
|
||||
unsigned int n; // denotes number of items in a leaf node
|
||||
Point_iterator data; // iterator to data in leaf node
|
||||
Point_d_iterator data; // iterator to data in leaf node
|
||||
|
||||
// private variables for internal nodes
|
||||
|
||||
|
|
@ -57,8 +57,8 @@ namespace CGAL {
|
|||
Separator sep;
|
||||
|
||||
// private variables for extended internal nodes
|
||||
NT low_val;
|
||||
NT high_val;
|
||||
FT low_val;
|
||||
FT high_val;
|
||||
|
||||
public:
|
||||
|
||||
|
|
@ -74,8 +74,8 @@ namespace CGAL {
|
|||
// members for leaf nodes only
|
||||
inline unsigned int size() const { return n;}
|
||||
|
||||
inline Point_iterator begin() const {return data;}
|
||||
inline Point_iterator end() const {return data + n;}
|
||||
inline Point_d_iterator begin() const {return data;}
|
||||
inline Point_d_iterator end() const {return data + n;}
|
||||
|
||||
// members for internal node and extended internal node
|
||||
|
||||
|
|
@ -85,15 +85,15 @@ namespace CGAL {
|
|||
// inline Separator& separator() {return sep; }
|
||||
// use instead
|
||||
|
||||
inline NT cutting_value() const
|
||||
inline FT cutting_value() const
|
||||
{return sep.cutting_value();}
|
||||
|
||||
inline int cutting_dimension() const
|
||||
{return sep.cutting_dimension();}
|
||||
|
||||
// members for extended internal node only
|
||||
inline NT low_value() const { return low_val; }
|
||||
inline NT high_value() const { return high_val; }
|
||||
inline FT low_value() const { return low_val; }
|
||||
inline FT high_value() const { return high_val; }
|
||||
|
||||
|
||||
Separator& separator() {
|
||||
|
|
@ -121,7 +121,7 @@ namespace CGAL {
|
|||
if (is_leaf())
|
||||
{
|
||||
if (n>0)
|
||||
for (Point_iterator i=begin(); i != end(); i++)
|
||||
for (Point_d_iterator i=begin(); i != end(); i++)
|
||||
{*it=**i; ++it;}
|
||||
}
|
||||
else {
|
||||
|
|
@ -136,7 +136,7 @@ namespace CGAL {
|
|||
Kd_tree_rectangle<TreeTraits>& b) {
|
||||
if (is_leaf()) {
|
||||
if (n>0)
|
||||
for (Point_iterator i=begin(); i != end(); i++)
|
||||
for (Point_d_iterator i=begin(); i != end(); i++)
|
||||
if (q.contains(**i))
|
||||
{*it=**i; ++it;}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,16 +30,16 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
template <class GeomTraits, class Point, class T>
|
||||
struct set_bounds : public std::unary_function<Point&, void> {
|
||||
template <class SearchTraits, class Point_d, class T>
|
||||
struct set_bounds : public std::unary_function<Point_d&, void> {
|
||||
int dim;
|
||||
T *lower;
|
||||
T *upper;
|
||||
set_bounds(int d, T *l, T *u) : dim(d), lower(l), upper(u) {}
|
||||
void operator() (Point& p) {
|
||||
void operator() (Point_d& p) {
|
||||
T h;
|
||||
typename GeomTraits::Construct_cartesian_const_iterator construct_it;
|
||||
typename GeomTraits::Cartesian_const_iterator pit = construct_it(p);
|
||||
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it;
|
||||
typename SearchTraits::Cartesian_const_iterator_d pit = construct_it(p);
|
||||
for (int i = 0; i < dim; ++i, ++pit) {
|
||||
h=(*pit);
|
||||
if (h < lower[i]) lower[i] = h;
|
||||
|
|
@ -48,7 +48,7 @@ namespace CGAL {
|
|||
}
|
||||
};
|
||||
|
||||
template <class GeomTraits, class P, class T>
|
||||
template <class SearchTraits, class P, class T>
|
||||
struct set_bounds_from_pointer : public std::unary_function<P, void> {
|
||||
int dim;
|
||||
T *lower;
|
||||
|
|
@ -57,8 +57,8 @@ namespace CGAL {
|
|||
dim(d), lower(l), upper(u) {}
|
||||
void operator() (P p) {
|
||||
T h;
|
||||
typename GeomTraits::Construct_cartesian_const_iterator construct_it;
|
||||
typename GeomTraits::Cartesian_const_iterator pit = construct_it(*p);
|
||||
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it;
|
||||
typename SearchTraits::Cartesian_const_iterator_d pit = construct_it(*p);
|
||||
for (int i = 0; i < dim; ++i, ++pit) {
|
||||
h=(*pit);
|
||||
if (h < lower[i]) lower[i] = h;
|
||||
|
|
@ -68,10 +68,10 @@ namespace CGAL {
|
|||
};
|
||||
|
||||
|
||||
template <class GeomTraits> class Kd_tree_rectangle {
|
||||
template <class SearchTraits> class Kd_tree_rectangle {
|
||||
public:
|
||||
typedef typename GeomTraits::NT NT;
|
||||
typedef NT T;
|
||||
typedef typename SearchTraits::FT FT;
|
||||
typedef FT T;
|
||||
|
||||
private:
|
||||
|
||||
|
|
@ -82,14 +82,14 @@ namespace CGAL {
|
|||
|
||||
public:
|
||||
|
||||
inline void set_upper_bound(int i, const NT& x) {
|
||||
inline void set_upper_bound(int i, const FT& x) {
|
||||
assert(i >= 0 && i < dim);
|
||||
assert(x >= lower_[i]);
|
||||
upper_[i] = x;
|
||||
set_max_span();
|
||||
}
|
||||
|
||||
inline void set_lower_bound(int i, const NT& x) {
|
||||
inline void set_lower_bound(int i, const FT& x) {
|
||||
assert(i >= 0 && i < dim);
|
||||
assert(x <= upper_[i]);
|
||||
lower_[i] = x;
|
||||
|
|
@ -97,10 +97,10 @@ namespace CGAL {
|
|||
}
|
||||
|
||||
inline void set_max_span() {
|
||||
NT span = upper_[0]-lower_[0];
|
||||
FT span = upper_[0]-lower_[0];
|
||||
max_span_coord_ = 0;
|
||||
for (int i = 1; i < dim; ++i) {
|
||||
NT tmp = upper_[i] - lower_[i];
|
||||
FT tmp = upper_[i] - lower_[i];
|
||||
if (span < tmp) {
|
||||
span = tmp;
|
||||
max_span_coord_ = i;
|
||||
|
|
@ -109,7 +109,7 @@ namespace CGAL {
|
|||
}
|
||||
|
||||
Kd_tree_rectangle(int d) :
|
||||
dim(d), lower_(new NT[d]), upper_(new NT[d])
|
||||
dim(d), lower_(new FT[d]), upper_(new FT[d])
|
||||
{
|
||||
std::fill(lower_, lower_ + dim, 0);
|
||||
std::fill(upper_, upper_ + dim, 0);
|
||||
|
|
@ -119,8 +119,8 @@ namespace CGAL {
|
|||
Kd_tree_rectangle() : dim(0), lower_(0), upper_(0) {}
|
||||
|
||||
|
||||
explicit Kd_tree_rectangle(const Kd_tree_rectangle<GeomTraits>& r) : dim(r.dim),
|
||||
lower_(new NT[dim]), upper_(new NT[dim]) {
|
||||
explicit Kd_tree_rectangle(const Kd_tree_rectangle<SearchTraits>& r) : dim(r.dim),
|
||||
lower_(new FT[dim]), upper_(new FT[dim]) {
|
||||
std::copy(r.lower_, r.lower_+dim, lower_);
|
||||
std::copy(r.upper_, r.upper_+dim, upper_);
|
||||
set_max_span();
|
||||
|
|
@ -128,12 +128,12 @@ namespace CGAL {
|
|||
|
||||
template <class PointIter>
|
||||
Kd_tree_rectangle(int d, PointIter begin, PointIter end)
|
||||
: dim(d), lower_(new NT[d]), upper_(new NT[d])
|
||||
: dim(d), lower_(new FT[d]), upper_(new FT[d])
|
||||
{
|
||||
// initialize with values of first point
|
||||
typename GeomTraits::Construct_cartesian_const_iterator construct_it;
|
||||
typename GeomTraits::Cartesian_const_iterator bit = construct_it(*begin);
|
||||
// typename GeomTraits::Cartesian_const_iterator be = construct_it(*begin,1);
|
||||
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it;
|
||||
typename SearchTraits::Cartesian_const_iterator_d bit = construct_it(*begin);
|
||||
// typename SearchTraits::Cartesian_const_iterator_d be = construct_it(*begin,1);
|
||||
|
||||
for (int i=0; i < dim; ++bit, ++i)
|
||||
{
|
||||
|
|
@ -141,7 +141,7 @@ namespace CGAL {
|
|||
}
|
||||
begin++;
|
||||
typedef typename std::iterator_traits<PointIter>::value_type P;
|
||||
std::for_each(begin, end, set_bounds<GeomTraits, P,T>(dim, lower_, upper_));
|
||||
std::for_each(begin, end, set_bounds<SearchTraits, P,T>(dim, lower_, upper_));
|
||||
set_max_span();
|
||||
}
|
||||
|
||||
|
|
@ -151,12 +151,12 @@ namespace CGAL {
|
|||
if (empty) { // no points
|
||||
for (int i=0; i < dim; ++i)
|
||||
{
|
||||
lower_[i]= NT(1); upper_[i]= NT(-1);
|
||||
lower_[i]= FT(1); upper_[i]= FT(-1);
|
||||
}
|
||||
} else {
|
||||
// initialize with values of first point
|
||||
typename GeomTraits::Construct_cartesian_const_iterator construct_it;
|
||||
typename GeomTraits::Cartesian_const_iterator bit = construct_it(**begin);
|
||||
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it;
|
||||
typename SearchTraits::Cartesian_const_iterator_d bit = construct_it(**begin);
|
||||
for (int i=0; i < dim; ++i, ++bit)
|
||||
{
|
||||
lower_[i]= *bit; upper_[i]=lower_[i];
|
||||
|
|
@ -165,22 +165,22 @@ namespace CGAL {
|
|||
typedef typename
|
||||
std::iterator_traits<PointPointerIter>::value_type P;
|
||||
std::for_each(begin, end,
|
||||
set_bounds_from_pointer<GeomTraits,P,T>(dim, lower_, upper_));
|
||||
set_bounds_from_pointer<SearchTraits,P,T>(dim, lower_, upper_));
|
||||
}
|
||||
set_max_span();
|
||||
}
|
||||
|
||||
inline int max_span_coord() const { return max_span_coord_; }
|
||||
|
||||
inline NT max_span() const {
|
||||
inline FT max_span() const {
|
||||
return upper_[max_span_coord_] - lower_[max_span_coord_];
|
||||
}
|
||||
|
||||
inline NT min_coord(int i) const {
|
||||
inline FT min_coord(int i) const {
|
||||
return lower_[i];
|
||||
}
|
||||
|
||||
inline NT max_coord(int i) const {
|
||||
inline FT max_coord(int i) const {
|
||||
return upper_[i];
|
||||
}
|
||||
|
||||
|
|
@ -190,12 +190,12 @@ namespace CGAL {
|
|||
for (int i=0; i < dim; ++i)
|
||||
s << lower_[i] << " ";
|
||||
// std::copy(lower_, lower_ + dim,
|
||||
// std::ostream_iterator<NT>(s," "));
|
||||
// std::ostream_iterator<FT>(s," "));
|
||||
s << "\n upper: ";
|
||||
for (int j=0; j < dim; ++j)
|
||||
s << upper_[j] << " ";
|
||||
// std::copy(upper_, upper_ + dim,
|
||||
// std::ostream_iterator<NT>(s," "));
|
||||
// std::ostream_iterator<FT>(s," "));
|
||||
s << "\n maximum span " << max_span() <<
|
||||
" at coordinate " << max_span_coord() << std::endl;
|
||||
return s;
|
||||
|
|
@ -205,7 +205,7 @@ namespace CGAL {
|
|||
// and returns upper half
|
||||
// Kd_tree_rectangle*
|
||||
void
|
||||
split(Kd_tree_rectangle& r, int d, NT value) {
|
||||
split(Kd_tree_rectangle& r, int d, FT value) {
|
||||
// assert(d >= 0 && d < dim);
|
||||
// assert(lower_[d] <= value && value <= upper_[d]);
|
||||
|
||||
|
|
@ -226,7 +226,7 @@ split(Kd_tree_rectangle& r, int d, NT value) {
|
|||
int dimension() const {return dim;}
|
||||
|
||||
|
||||
Kd_tree_rectangle<GeomTraits>& operator= (const Kd_tree_rectangle<GeomTraits>& r) {
|
||||
Kd_tree_rectangle<SearchTraits>& operator= (const Kd_tree_rectangle<SearchTraits>& r) {
|
||||
|
||||
if (this != &r) {
|
||||
std::copy(r.lower_, r.lower_+dim, lower_);
|
||||
|
|
@ -240,8 +240,8 @@ split(Kd_tree_rectangle& r, int d, NT value) {
|
|||
|
||||
}; // of class Kd_tree_rectangle
|
||||
|
||||
template <class GeomTraits>
|
||||
std::ostream& operator<< (std::ostream& s, Kd_tree_rectangle<GeomTraits>& r) {
|
||||
template <class SearchTraits>
|
||||
std::ostream& operator<< (std::ostream& s, Kd_tree_rectangle<SearchTraits>& r) {
|
||||
return r.print(s);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,13 +29,13 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
template <class GeomTraits, class QueryItem>
|
||||
template <class SearchTraits, class QueryItem>
|
||||
class Manhattan_distance_iso_box_point {
|
||||
|
||||
public:
|
||||
|
||||
typedef typename GeomTraits::Point Point;
|
||||
typedef typename GeomTraits::NT NT;
|
||||
typedef typename SearchTraits::Point_d Point_d;
|
||||
typedef typename SearchTraits::FT FT;
|
||||
typedef QueryItem Query_item;
|
||||
|
||||
|
||||
|
|
@ -49,10 +49,10 @@ namespace CGAL {
|
|||
|
||||
~Manhattan_distance_iso_box_point() {}
|
||||
|
||||
inline NT distance(const QueryItem& q, const Point& p) {
|
||||
NT distance = NT(0);
|
||||
typename GeomTraits::Construct_cartesian_const_iterator construct_it;
|
||||
typename GeomTraits::Cartesian_const_iterator qmaxit = construct_it(q.max()),
|
||||
inline FT transformed_distance(const QueryItem& q, const Point_d& p) {
|
||||
FT distance = FT(0);
|
||||
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it;
|
||||
typename SearchTraits::Cartesian_const_iterator_d qmaxit = construct_it(q.max()),
|
||||
qe = construct_it(q.max(),1), qminit = construct_it(q.min()),
|
||||
pit = construct_it(p);
|
||||
for (; qmaxit != qe; ++qmaxit) {
|
||||
|
|
@ -65,11 +65,11 @@ namespace CGAL {
|
|||
}
|
||||
|
||||
|
||||
inline NT min_distance_to_rectangle(const QueryItem& q,
|
||||
const Kd_tree_rectangle<GeomTraits>& r) {
|
||||
NT distance = NT(0);
|
||||
typename GeomTraits::Construct_cartesian_const_iterator construct_it;
|
||||
typename GeomTraits::Cartesian_const_iterator qmaxit = construct_it(q.max()),
|
||||
inline FT min_distance_to_rectangle(const QueryItem& q,
|
||||
const Kd_tree_rectangle<SearchTraits>& r) {
|
||||
FT distance = FT(0);
|
||||
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it;
|
||||
typename SearchTraits::Cartesian_const_iterator_d qmaxit = construct_it(q.max()),
|
||||
qe = construct_it(q.max(),1), qminit = construct_it(q.min());
|
||||
for (unsigned int i = 0; qmaxit != qe; ++ qmaxit, ++i) {
|
||||
if (r.min_coord(i)>(*qmaxit))
|
||||
|
|
@ -81,12 +81,12 @@ namespace CGAL {
|
|||
}
|
||||
|
||||
inline
|
||||
NT
|
||||
FT
|
||||
max_distance_to_rectangle(const QueryItem& q,
|
||||
const Kd_tree_rectangle<GeomTraits>& r) {
|
||||
NT distance=NT(0);
|
||||
typename GeomTraits::Construct_cartesian_const_iterator construct_it;
|
||||
typename GeomTraits::Cartesian_const_iterator qmaxit = construct_it(q.max()),
|
||||
const Kd_tree_rectangle<SearchTraits>& r) {
|
||||
FT distance=FT(0);
|
||||
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it;
|
||||
typename SearchTraits::Cartesian_const_iterator_d qmaxit = construct_it(q.max()),
|
||||
qe = construct_it(q.max(),1), qminit = construct_it(q.min());
|
||||
for (unsigned int i = 0; qmaxit != qe; ++ qmaxit, ++i) {
|
||||
if ( r.max_coord(i)-(*qminit) >(*qmaxit)-r.min_coord(i) )
|
||||
|
|
@ -98,15 +98,15 @@ namespace CGAL {
|
|||
}
|
||||
|
||||
inline
|
||||
NT
|
||||
transformed_distance(NT d)
|
||||
FT
|
||||
transformed_distance(FT d)
|
||||
{
|
||||
return d;
|
||||
}
|
||||
|
||||
inline
|
||||
NT
|
||||
inverse_of_transformed_distance(NT d)
|
||||
FT
|
||||
inverse_of_transformed_distance(FT d)
|
||||
{
|
||||
return d;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,34 +27,30 @@
|
|||
#include <list>
|
||||
#include <queue>
|
||||
#include <memory>
|
||||
#include <CGAL/Kd_tree_node.h>
|
||||
#include <CGAL/Kd_tree.h>
|
||||
#include <CGAL/Euclidean_distance.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
template <class GeomTraits,
|
||||
class Distance_=Euclidean_distance<GeomTraits>,
|
||||
class Splitter_ = Sliding_midpoint<GeomTraits>,
|
||||
class Tree_=Kd_tree<GeomTraits, Splitter_, Tag_true> >
|
||||
template <class SearchTraits,
|
||||
class Distance_=Euclidean_distance<SearchTraits>,
|
||||
class Splitter_ = Sliding_midpoint<SearchTraits>,
|
||||
class Tree_=Kd_tree<SearchTraits, Splitter_, Tag_true> >
|
||||
class Orthogonal_incremental_neighbor_search {
|
||||
|
||||
public:
|
||||
typedef Splitter_ Splitter;
|
||||
typedef Tree_ Tree;
|
||||
typedef Distance_ Distance;
|
||||
typedef typename GeomTraits::Point Point;
|
||||
typedef Point Query_item;
|
||||
typedef typename GeomTraits::NT NT;
|
||||
typedef typename Tree::Point_iterator Point_iterator;
|
||||
typedef typename SearchTraits::Point_d Point_d;
|
||||
typedef Point_d Query_item;
|
||||
typedef typename SearchTraits::FT FT;
|
||||
typedef typename Tree::Point_d_iterator Point_d_iterator;
|
||||
typedef typename Tree::Node_handle Node_handle;
|
||||
|
||||
typedef std::pair<Point,NT> Point_with_distance;
|
||||
typedef std::pair<Node_handle,NT> Node_with_distance;
|
||||
typedef std::pair<Point_d,FT> Point_with_distance;
|
||||
typedef std::pair<Node_handle,FT> Node_with_distance;
|
||||
typedef std::vector<Node_with_distance*> Node_with_distance_vector;
|
||||
typedef std::vector<Point_with_distance*> Point_with_distance_vector;
|
||||
|
||||
|
|
@ -72,17 +68,17 @@ class Iterator_implementation {
|
|||
private:
|
||||
|
||||
|
||||
NT multiplication_factor;
|
||||
FT multiplication_factor;
|
||||
|
||||
Point* query_point;
|
||||
Point_d* query_point;
|
||||
|
||||
int total_item_number;
|
||||
|
||||
NT distance_to_root;
|
||||
FT distance_to_root;
|
||||
|
||||
bool search_nearest_neighbour;
|
||||
|
||||
NT rd;
|
||||
FT rd;
|
||||
|
||||
class Priority_higher
|
||||
{
|
||||
|
|
@ -140,7 +136,7 @@ class Iterator_implementation {
|
|||
|
||||
// constructor
|
||||
Iterator_implementation(Tree& tree, Query_item& q, const Distance& tr,
|
||||
NT Eps=NT(0.0), bool search_nearest=true)
|
||||
FT Eps=FT(0.0), bool search_nearest=true)
|
||||
{
|
||||
PriorityQueue= new std::priority_queue<Node_with_distance*,
|
||||
Node_with_distance_vector,
|
||||
|
|
@ -156,7 +152,7 @@ class Iterator_implementation {
|
|||
reference_count=1;
|
||||
Orthogonal_distance_instance= new Distance(tr);
|
||||
multiplication_factor=
|
||||
Orthogonal_distance_instance->transformed_distance(NT(1.0)+Eps);
|
||||
Orthogonal_distance_instance->transformed_distance(FT(1.0)+Eps);
|
||||
|
||||
// if (search_nearest)
|
||||
distance_to_root=
|
||||
|
|
@ -263,26 +259,26 @@ class Iterator_implementation {
|
|||
next_neighbour_found=
|
||||
(rd < multiplication_factor*Item_PriorityQueue->top()->second);
|
||||
}
|
||||
typename GeomTraits::Construct_cartesian_const_iterator construct_it;
|
||||
typename GeomTraits::Cartesian_const_iterator query_point_it = construct_it(*query_point);
|
||||
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it;
|
||||
typename SearchTraits::Cartesian_const_iterator_d query_point_it = construct_it(*query_point);
|
||||
// otherwise browse the tree further
|
||||
while ((!next_neighbour_found) && (!PriorityQueue->empty())) {
|
||||
Node_with_distance* The_node_top=PriorityQueue->top();
|
||||
Node_handle N= The_node_top->first;
|
||||
PriorityQueue->pop();
|
||||
delete The_node_top;
|
||||
NT copy_rd=rd;
|
||||
FT copy_rd=rd;
|
||||
while (!(N->is_leaf())) { // compute new distance
|
||||
number_of_internal_nodes_visited++;
|
||||
int new_cut_dim=N->cutting_dimension();
|
||||
NT old_off, new_rd;
|
||||
NT new_off =
|
||||
FT old_off, new_rd;
|
||||
FT new_off =
|
||||
*(query_point_it + new_cut_dim) -
|
||||
N->cutting_value();
|
||||
if (new_off < NT(0.0)) {
|
||||
if (new_off < FT(0.0)) {
|
||||
old_off=
|
||||
*(query_point_it + new_cut_dim)-N->low_value();
|
||||
if (old_off>NT(0.0)) old_off=NT(0.0);
|
||||
if (old_off>FT(0.0)) old_off=FT(0.0);
|
||||
new_rd=
|
||||
Orthogonal_distance_instance->
|
||||
new_distance(copy_rd,old_off,new_off,new_cut_dim);
|
||||
|
|
@ -305,7 +301,7 @@ class Iterator_implementation {
|
|||
else { // compute new distance
|
||||
old_off= N->high_value() -
|
||||
*(query_point_it+new_cut_dim);
|
||||
if (old_off>NT(0.0)) old_off=NT(0.0);
|
||||
if (old_off>FT(0.0)) old_off=FT(0.0);
|
||||
new_rd=Orthogonal_distance_instance->
|
||||
new_distance(copy_rd,old_off,new_off,new_cut_dim);
|
||||
assert(new_rd >= copy_rd);
|
||||
|
|
@ -327,11 +323,11 @@ class Iterator_implementation {
|
|||
// n is a leaf
|
||||
number_of_leaf_nodes_visited++;
|
||||
if (N->size() > 0) {
|
||||
for (Point_iterator it=N->begin(); it != N->end(); it++) {
|
||||
for (Point_d_iterator it=N->begin(); it != N->end(); it++) {
|
||||
number_of_items_visited++;
|
||||
NT distance_to_query_point=
|
||||
FT distance_to_query_point=
|
||||
Orthogonal_distance_instance->
|
||||
distance(*query_point,**it);
|
||||
transformed_distance(*query_point,**it);
|
||||
Point_with_distance *NN_Candidate=
|
||||
new Point_with_distance(**it,distance_to_query_point);
|
||||
Item_PriorityQueue->push(NN_Candidate);
|
||||
|
|
@ -373,13 +369,13 @@ class iterator;
|
|||
|
||||
typedef std::vector<Point_with_distance*> Point_with_distance_vector;
|
||||
|
||||
typedef std::vector<NT> Distance_vector;
|
||||
typedef std::vector<FT> Distance_vector;
|
||||
|
||||
public:
|
||||
|
||||
// constructor
|
||||
Orthogonal_incremental_neighbor_search(Tree& tree,
|
||||
Query_item& q, NT Eps = NT(0.0),
|
||||
Query_item& q, FT Eps = FT(0.0),
|
||||
bool search_nearest=true, const Distance& tr=Distance())
|
||||
: start(tree,q,tr,Eps,search_nearest),
|
||||
past_the_end()
|
||||
|
|
@ -428,7 +424,7 @@ class iterator;
|
|||
}
|
||||
|
||||
// constructor
|
||||
iterator(Tree& tree, Query_item& q, const Distance& tr=Distance(), NT eps=NT(0.0),
|
||||
iterator(Tree& tree, Query_item& q, const Distance& tr=Distance(), FT eps=FT(0.0),
|
||||
bool search_nearest=true){
|
||||
Ptr_implementation =
|
||||
new Iterator_implementation(tree, q, tr, eps, search_nearest);
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
template <class GeomTraits,
|
||||
class Distance_=Euclidean_distance<GeomTraits>,
|
||||
class Splitter_=Sliding_midpoint<GeomTraits> ,
|
||||
class Tree_=Kd_tree<GeomTraits, Splitter_, Tag_true> >
|
||||
template <class SearchTraits,
|
||||
class Distance_=Euclidean_distance<SearchTraits>,
|
||||
class Splitter_=Sliding_midpoint<SearchTraits> ,
|
||||
class Tree_=Kd_tree<SearchTraits, Splitter_, Tag_true> >
|
||||
class Orthogonal_k_neighbor_search {
|
||||
|
||||
public:
|
||||
|
|
@ -45,14 +45,14 @@ public:
|
|||
typedef Splitter_ Splitter;
|
||||
typedef Tree_ Tree;
|
||||
typedef Distance_ Distance;
|
||||
typedef typename GeomTraits::Point Point;
|
||||
typedef typename GeomTraits::Point Query_item;
|
||||
typedef typename GeomTraits::NT NT;
|
||||
typedef std::pair<Point,NT> Point_with_distance;
|
||||
typedef typename SearchTraits::Point_d Point_d;
|
||||
typedef typename SearchTraits::Point_d Query_item;
|
||||
typedef typename SearchTraits::FT FT;
|
||||
typedef std::pair<Point_d,FT> Point_with_distance;
|
||||
|
||||
typedef typename Tree::Node_handle Node_handle;
|
||||
|
||||
typedef typename Tree::Point_iterator Point_iterator;
|
||||
typedef typename Tree::Point_d_iterator Point_d_iterator;
|
||||
|
||||
private:
|
||||
|
||||
|
|
@ -62,13 +62,17 @@ int number_of_items_visited;
|
|||
|
||||
bool search_nearest;
|
||||
|
||||
NT multiplication_factor;
|
||||
FT multiplication_factor;
|
||||
Query_item query_object;
|
||||
int total_item_number;
|
||||
NT distance_to_root;
|
||||
FT distance_to_root;
|
||||
|
||||
typedef std::list<Point_with_distance> NN_list;
|
||||
|
||||
public:
|
||||
typedef typename NN_list::const_iterator iterator;
|
||||
private:
|
||||
|
||||
NN_list l;
|
||||
int max_k;
|
||||
int actual_k;
|
||||
|
|
@ -76,7 +80,7 @@ int actual_k;
|
|||
|
||||
Distance* distance_instance;
|
||||
|
||||
inline bool branch(NT distance) {
|
||||
inline bool branch(FT distance) {
|
||||
if (actual_k<max_k) return true;
|
||||
else
|
||||
if (search_nearest) return
|
||||
|
|
@ -86,7 +90,7 @@ Distance* distance_instance;
|
|||
l.begin()->second * multiplication_factor);
|
||||
};
|
||||
|
||||
inline void insert(Point* I, NT dist) {
|
||||
inline void insert(Point_d* I, FT dist) {
|
||||
bool insert;
|
||||
if (actual_k<max_k) insert=true;
|
||||
else
|
||||
|
|
@ -111,7 +115,7 @@ Distance* distance_instance;
|
|||
|
||||
|
||||
public:
|
||||
|
||||
/*
|
||||
template<class OutputIterator>
|
||||
OutputIterator the_k_neighbors(OutputIterator res)
|
||||
{
|
||||
|
|
@ -119,11 +123,21 @@ Distance* distance_instance;
|
|||
for (; it != l.end(); it++) { *res= *it; res++; }
|
||||
return res;
|
||||
}
|
||||
*/
|
||||
iterator begin() const
|
||||
{
|
||||
return l.begin();
|
||||
}
|
||||
|
||||
iterator end() const
|
||||
{
|
||||
return l.end();
|
||||
}
|
||||
|
||||
|
||||
// constructor
|
||||
Orthogonal_k_neighbor_search(Tree& tree, const Query_item& q,
|
||||
int k=1, NT Eps=NT(0.0), bool Search_nearest=true, const Distance& d=Distance()) {
|
||||
int k=1, FT Eps=FT(0.0), bool Search_nearest=true, const Distance& d=Distance()) {
|
||||
|
||||
distance_instance=new Distance(d);
|
||||
|
||||
|
|
@ -175,30 +189,30 @@ Distance* distance_instance;
|
|||
|
||||
private:
|
||||
|
||||
void compute_neighbors_orthogonally(Node_handle N, NT rd) {
|
||||
void compute_neighbors_orthogonally(Node_handle N, FT rd) {
|
||||
|
||||
typename GeomTraits::Construct_cartesian_const_iterator construct_it;
|
||||
typename GeomTraits::Cartesian_const_iterator query_object_it = construct_it(query_object);
|
||||
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it;
|
||||
typename SearchTraits::Cartesian_const_iterator_d query_object_it = construct_it(query_object);
|
||||
if (!(N->is_leaf())) {
|
||||
number_of_internal_nodes_visited++;
|
||||
int new_cut_dim=N->cutting_dimension();
|
||||
NT old_off, new_rd;
|
||||
NT new_off =
|
||||
FT old_off, new_rd;
|
||||
FT new_off =
|
||||
*(query_object_it + new_cut_dim) -
|
||||
N->cutting_value();
|
||||
if ( ((new_off < NT(0.0)) && (search_nearest)) ||
|
||||
(( new_off >= NT(0.0)) && (!search_nearest)) ) {
|
||||
if ( ((new_off < FT(0.0)) && (search_nearest)) ||
|
||||
(( new_off >= FT(0.0)) && (!search_nearest)) ) {
|
||||
compute_neighbors_orthogonally(N->lower(),rd);
|
||||
if (search_nearest) {
|
||||
old_off= *(query_object_it + new_cut_dim)-
|
||||
N->low_value();
|
||||
if (old_off>NT(0.0)) old_off=NT(0.0);
|
||||
if (old_off>FT(0.0)) old_off=FT(0.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
old_off= *(query_object_it + new_cut_dim)
|
||||
- N->high_value();
|
||||
if (old_off<NT(0.0)) old_off=NT(0.0);
|
||||
if (old_off<FT(0.0)) old_off=FT(0.0);
|
||||
}
|
||||
new_rd=
|
||||
distance_instance->
|
||||
|
|
@ -212,13 +226,13 @@ Distance* distance_instance;
|
|||
if (search_nearest) {
|
||||
old_off= N->high_value() -
|
||||
*(query_object_it + new_cut_dim);
|
||||
if (old_off>NT(0.0)) old_off=NT(0.0);
|
||||
if (old_off>FT(0.0)) old_off=FT(0.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
old_off= N->low_value() -
|
||||
*(query_object_it + new_cut_dim);
|
||||
if (old_off<NT(0.0)) old_off=NT(0.0);
|
||||
if (old_off<FT(0.0)) old_off=FT(0.0);
|
||||
}
|
||||
new_rd=
|
||||
distance_instance->
|
||||
|
|
@ -233,11 +247,11 @@ Distance* distance_instance;
|
|||
// n is a leaf
|
||||
number_of_leaf_nodes_visited++;
|
||||
if (N->size() > 0)
|
||||
for (Point_iterator it=N->begin(); it != N->end(); it++) {
|
||||
for (Point_d_iterator it=N->begin(); it != N->end(); it++) {
|
||||
number_of_items_visited++;
|
||||
NT distance_to_query_object=
|
||||
FT distance_to_query_object=
|
||||
distance_instance->
|
||||
distance(query_object,**it);
|
||||
transformed_distance(query_object,**it);
|
||||
insert(*it,distance_to_query_object);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,21 +23,21 @@
|
|||
#ifndef CGAL_PLANE_SEPARATOR_H
|
||||
#define CGAL_PLANE_SEPARATOR_H
|
||||
namespace CGAL {
|
||||
template < class NT> class Plane_separator {
|
||||
template < class FT> class Plane_separator {
|
||||
|
||||
public:
|
||||
|
||||
int cutting_dim;
|
||||
NT cutting_val;
|
||||
FT cutting_val;
|
||||
|
||||
inline int cutting_dimension() const { return cutting_dim;}
|
||||
inline NT cutting_value() const { return cutting_val;}
|
||||
inline FT cutting_value() const { return cutting_val;}
|
||||
|
||||
void set_cutting_dimension(int d) {
|
||||
cutting_dim=d;
|
||||
}
|
||||
|
||||
void set_cutting_value(NT val) {
|
||||
void set_cutting_value(FT val) {
|
||||
cutting_val=val;
|
||||
}
|
||||
|
||||
|
|
@ -46,13 +46,13 @@ template < class NT> class Plane_separator {
|
|||
return i[cutting_dimension()] < cutting_value();
|
||||
}
|
||||
|
||||
Plane_separator(const int d, const NT& v) :
|
||||
Plane_separator(const int d, const FT& v) :
|
||||
cutting_dim(d), cutting_val(v) {}
|
||||
Plane_separator(const Plane_separator<NT>& s) :
|
||||
Plane_separator(const Plane_separator<FT>& s) :
|
||||
cutting_dim(s.cutting_dimension()),
|
||||
cutting_val(s.cutting_value()) {}
|
||||
explicit Plane_separator() : cutting_dim(0), cutting_val(0) {}
|
||||
Plane_separator<NT>& operator= (const Plane_separator<NT>& s) {
|
||||
Plane_separator<FT>& operator= (const Plane_separator<FT>& s) {
|
||||
cutting_dim = s.cutting_dimension();
|
||||
cutting_val = s.cutting_value();
|
||||
return *this;
|
||||
|
|
@ -62,8 +62,8 @@ template < class NT> class Plane_separator {
|
|||
|
||||
};
|
||||
|
||||
template < class NT>
|
||||
std::ostream& operator<< (std::ostream& s, Plane_separator<NT>& x) {
|
||||
template < class FT>
|
||||
std::ostream& operator<< (std::ostream& s, Plane_separator<FT>& x) {
|
||||
s << "\n Separator coordinate: " << x.cutting_dimension() <<
|
||||
" value: " << x.cutting_value() << "\n";
|
||||
return s;
|
||||
|
|
|
|||
|
|
@ -32,32 +32,32 @@
|
|||
#include <CGAL/Kd_tree_rectangle.h>
|
||||
namespace CGAL {
|
||||
|
||||
template <class GeomTraits> class Point_container {
|
||||
template <class SearchTraits> class Point_container {
|
||||
|
||||
private:
|
||||
typedef typename GeomTraits::Point Point;
|
||||
typedef std::vector<Point*> Point_vector;
|
||||
typedef Point_container<Point> Self;
|
||||
typedef typename SearchTraits::Point_d Point_d;
|
||||
typedef std::vector<Point_d*> Point_vector;
|
||||
typedef Point_container<Point_d> Self;
|
||||
|
||||
public:
|
||||
typedef typename GeomTraits::NT NT;
|
||||
typedef std::list<Point*> Point_list;
|
||||
typedef typename SearchTraits::FT FT;
|
||||
typedef std::list<Point_d*> Point_list;
|
||||
typedef Point_list::iterator iterator;
|
||||
|
||||
private:
|
||||
Point_list p_list; // list of pointers to points
|
||||
int built_coord; // a coordinate for which the pointer list is built
|
||||
unsigned int the_size;
|
||||
Kd_tree_rectangle<GeomTraits> bbox; // bounding box, i.e. rectangle of node
|
||||
Kd_tree_rectangle<GeomTraits> tbox; // tight bounding box,
|
||||
Kd_tree_rectangle<SearchTraits> bbox; // bounding box, i.e. rectangle of node
|
||||
Kd_tree_rectangle<SearchTraits> tbox; // tight bounding box,
|
||||
// i.e. minimal enclosing bounding
|
||||
// box of points
|
||||
|
||||
public:
|
||||
|
||||
inline const Kd_tree_rectangle<GeomTraits>& bounding_box() const { return bbox; }
|
||||
inline const Kd_tree_rectangle<SearchTraits>& bounding_box() const { return bbox; }
|
||||
|
||||
inline const Kd_tree_rectangle<GeomTraits>& tight_bounding_box() const
|
||||
inline const Kd_tree_rectangle<SearchTraits>& tight_bounding_box() const
|
||||
{ return tbox; }
|
||||
|
||||
inline int dimension() const { return bbox.dimension(); }
|
||||
|
|
@ -70,35 +70,35 @@ namespace CGAL {
|
|||
// coordinate of the maximal tight span
|
||||
inline int max_tight_span_coord() const { return tbox.max_span_coord(); }
|
||||
|
||||
inline NT max_span_lower() const
|
||||
inline FT max_span_lower() const
|
||||
{ return bbox.min_coord(max_span_coord());}
|
||||
|
||||
inline NT max_tight_span_lower() const {
|
||||
inline FT max_tight_span_lower() const {
|
||||
return tbox.min_coord(max_tight_span_coord());}
|
||||
|
||||
inline NT max_span_upper() const
|
||||
inline FT max_span_upper() const
|
||||
{ return bbox.max_coord(max_span_coord());}
|
||||
|
||||
inline NT max_tight_span_upper() const {
|
||||
inline FT max_tight_span_upper() const {
|
||||
return tbox.max_coord(max_tight_span_coord());}
|
||||
|
||||
inline NT max_spread() const
|
||||
inline FT max_spread() const
|
||||
{ return max_span_upper() - max_span_lower(); }
|
||||
|
||||
inline NT max_tight_spread() const {
|
||||
inline FT max_tight_spread() const {
|
||||
return max_tight_span_upper() - max_tight_span_lower(); }
|
||||
|
||||
|
||||
int max_tight_span_coord_balanced(NT Aspect_ratio) const {
|
||||
int max_tight_span_coord_balanced(FT Aspect_ratio) const {
|
||||
int cut_dim(-1);
|
||||
NT max_spread_points(NT(-1));
|
||||
NT max_length=max_spread(); // length of longest side of box
|
||||
FT max_spread_points(FT(-1));
|
||||
FT max_length=max_spread(); // length of longest side of box
|
||||
int dim=dimension();
|
||||
for (int d=0; d<dim; d++) {
|
||||
NT length=bbox.max_coord(d)-bbox.min_coord(d);
|
||||
FT length=bbox.max_coord(d)-bbox.min_coord(d);
|
||||
|
||||
if (NT(2)*max_length/length <= Aspect_ratio) {
|
||||
NT spread=tbox.max_coord(d)-tbox.min_coord(d);
|
||||
if (FT(2)*max_length/length <= Aspect_ratio) {
|
||||
FT spread=tbox.max_coord(d)-tbox.min_coord(d);
|
||||
|
||||
if (spread > max_spread_points) {
|
||||
max_spread_points = spread;
|
||||
|
|
@ -110,41 +110,41 @@ namespace CGAL {
|
|||
return cut_dim;
|
||||
}
|
||||
|
||||
NT max_span_upper_without_dim(int d) const {
|
||||
NT max_span(NT(0));
|
||||
FT max_span_upper_without_dim(int d) const {
|
||||
FT max_span(FT(0));
|
||||
int dim=dimension();
|
||||
for (int i=0; i<dim; i++) {
|
||||
NT span = bbox.max_coord(i)-bbox.min_coord(i);
|
||||
FT span = bbox.max_coord(i)-bbox.min_coord(i);
|
||||
if (d != i && span > max_span) max_span=span;
|
||||
}
|
||||
return max_span;
|
||||
}
|
||||
|
||||
NT balanced_fair(int d, NT Aspect_ratio) {
|
||||
NT small_piece =
|
||||
FT balanced_fair(int d, FT Aspect_ratio) {
|
||||
FT small_piece =
|
||||
max_span_upper_without_dim(d) / Aspect_ratio;
|
||||
NT low_cut =
|
||||
FT low_cut =
|
||||
bbox.min_coord(d) + small_piece; // lowest legal cut;
|
||||
NT high_cut =
|
||||
FT high_cut =
|
||||
bbox.max_coord(d) - small_piece; //highest legal cut;
|
||||
// assert (high_cut >= low_cut);
|
||||
NT split_value = median(d);
|
||||
FT split_value = median(d);
|
||||
if (split_value < low_cut) split_value=low_cut;
|
||||
if (split_value > high_cut) split_value=high_cut;
|
||||
return split_value;
|
||||
}
|
||||
|
||||
NT balanced_sliding_fair(int d, NT Aspect_ratio) {
|
||||
NT small_piece =
|
||||
FT balanced_sliding_fair(int d, FT Aspect_ratio) {
|
||||
FT small_piece =
|
||||
max_span_upper_without_dim(d) / Aspect_ratio;
|
||||
NT low_cut =
|
||||
FT low_cut =
|
||||
bbox.min_coord(d) + small_piece; // lowest legal cut;
|
||||
NT high_cut =
|
||||
FT high_cut =
|
||||
bbox.max_coord(d) - small_piece; //highest legal cut;
|
||||
// assert (high_cut >= low_cut);
|
||||
NT split_value = median(d);
|
||||
NT max_span_lower = tbox.min_coord(d);
|
||||
NT max_span_upper = tbox.max_coord(d);
|
||||
FT split_value = median(d);
|
||||
FT max_span_lower = tbox.min_coord(d);
|
||||
FT max_span_upper = tbox.max_coord(d);
|
||||
if (split_value < low_cut) split_value= max_span_lower;
|
||||
if (split_value > high_cut) split_value = max_span_upper;
|
||||
return split_value;
|
||||
|
|
@ -172,7 +172,7 @@ namespace CGAL {
|
|||
|
||||
|
||||
|
||||
bbox = Kd_tree_rectangle<GeomTraits>(d, begin, end);
|
||||
bbox = Kd_tree_rectangle<SearchTraits>(d, begin, end);
|
||||
tbox = bbox;
|
||||
|
||||
// build list
|
||||
|
|
@ -187,7 +187,7 @@ namespace CGAL {
|
|||
Point_container(const int d) :
|
||||
the_size(0), bbox(d), tbox(d) {}
|
||||
|
||||
void swap(Point_container<GeomTraits>& c) {
|
||||
void swap(Point_container<SearchTraits>& c) {
|
||||
|
||||
swap(p_list,c.p_list);
|
||||
|
||||
|
|
@ -203,12 +203,12 @@ namespace CGAL {
|
|||
c.built_coord = h;
|
||||
|
||||
// work-around
|
||||
Kd_tree_rectangle<GeomTraits> h_bbox(bbox);
|
||||
Kd_tree_rectangle<SearchTraits> h_bbox(bbox);
|
||||
bbox = c.bbox;
|
||||
c.bbox = h_bbox;
|
||||
|
||||
// work-around
|
||||
Kd_tree_rectangle<GeomTraits> h_tbox(tbox);
|
||||
Kd_tree_rectangle<SearchTraits> h_tbox(tbox);
|
||||
tbox = c.tbox;
|
||||
c.tbox = h_tbox;
|
||||
|
||||
|
|
@ -229,7 +229,7 @@ namespace CGAL {
|
|||
|
||||
// note that splitting is restricted to the built coordinate
|
||||
template <class Separator>
|
||||
void split(Point_container<GeomTraits>& c, Separator& sep,
|
||||
void split(Point_container<SearchTraits>& c, Separator& sep,
|
||||
bool sliding=false) {
|
||||
|
||||
assert(dimension()==c.dimension());
|
||||
|
|
@ -240,7 +240,7 @@ namespace CGAL {
|
|||
// bool test_validity=false;
|
||||
|
||||
const int split_coord = sep.cutting_dimension();
|
||||
const NT cutting_value = sep.cutting_value();
|
||||
const FT cutting_value = sep.cutting_value();
|
||||
|
||||
built_coord=split_coord;
|
||||
c.built_coord=split_coord;
|
||||
|
|
@ -248,8 +248,8 @@ namespace CGAL {
|
|||
|
||||
iterator pt=p_list.begin();
|
||||
|
||||
typename GeomTraits::Construct_cartesian_const_iterator construct_it;
|
||||
typename GeomTraits::Cartesian_const_iterator ptit;
|
||||
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it;
|
||||
typename SearchTraits::Cartesian_const_iterator_d ptit;
|
||||
|
||||
for (; (pt != p_list.end()); ++pt) {
|
||||
|
||||
|
|
@ -263,7 +263,7 @@ namespace CGAL {
|
|||
if (sliding) { // avoid empty lists
|
||||
if (l_lower.empty()) {
|
||||
iterator pt_min=l_upper.begin();
|
||||
NT min_value=bbox.max_coord(built_coord);
|
||||
FT min_value=bbox.max_coord(built_coord);
|
||||
for (pt=l_upper.begin(); (pt != l_upper.end()); ++pt) {
|
||||
ptit = construct_it((*(*pt)));
|
||||
if ( *(ptit+split_coord) < min_value) {
|
||||
|
|
@ -275,7 +275,7 @@ namespace CGAL {
|
|||
}
|
||||
if (l_upper.empty()) {
|
||||
iterator pt_max=l_lower.begin();
|
||||
NT max_value=bbox.min_coord(built_coord);
|
||||
FT max_value=bbox.min_coord(built_coord);
|
||||
for (pt=l_lower.begin(); (pt != l_lower.end()); ++pt) {
|
||||
ptit = construct_it((*(*pt)));
|
||||
if ( *(ptit+split_coord) > max_value) {
|
||||
|
|
@ -311,51 +311,51 @@ namespace CGAL {
|
|||
|
||||
|
||||
|
||||
template <class GeomTraits2, class Value>
|
||||
template <class SearchTraits2, class Value>
|
||||
struct comp_coord_val {
|
||||
|
||||
private:
|
||||
Value coord;
|
||||
|
||||
typedef typename GeomTraits2::Point Point;
|
||||
typedef typename SearchTraits2::Point_d Point_d;
|
||||
public:
|
||||
comp_coord_val (const Value& coordinate) : coord(coordinate) {}
|
||||
|
||||
bool operator() (const Point *a, const Point *b) {
|
||||
typename GeomTraits2::Construct_cartesian_const_iterator construct_it;
|
||||
typename GeomTraits2::Cartesian_const_iterator ait = construct_it(*a),
|
||||
bool operator() (const Point_d *a, const Point_d *b) {
|
||||
typename SearchTraits2::Construct_cartesian_const_iterator_d construct_it;
|
||||
typename SearchTraits2::Cartesian_const_iterator_d ait = construct_it(*a),
|
||||
bit = construct_it(*b);
|
||||
return *(ait+coord) < *(bit+coord);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
NT median(const int split_coord) {
|
||||
FT median(const int split_coord) {
|
||||
|
||||
#ifdef CGAL_CFG_RWSTD_NO_MEMBER_TEMPLATES
|
||||
Point_vector p_vector;
|
||||
std::copy(p_list.begin(), p_list.end(), std::back_inserter(p_vector));
|
||||
std::sort(p_vector.begin(),p_vector.end(),comp_coord_val<GeomTraits,int>(split_coord));
|
||||
std::sort(p_vector.begin(),p_vector.end(),comp_coord_val<SearchTraits,int>(split_coord));
|
||||
p_list.clear();
|
||||
std::copy(p_vector.begin(), p_vector.end(), std::back_inserter(p_list));
|
||||
#else
|
||||
p_list.sort(comp_coord_val<GeomTraits,int>(split_coord));
|
||||
p_list.sort(comp_coord_val<SearchTraits,int>(split_coord));
|
||||
#endif
|
||||
|
||||
iterator median_point_ptr = p_list.begin();
|
||||
for (unsigned int i = 0; i < the_size/2-1; i++,
|
||||
median_point_ptr++) {}
|
||||
|
||||
typename GeomTraits::Construct_cartesian_const_iterator construct_it;
|
||||
typename GeomTraits::Cartesian_const_iterator mpit = construct_it((*(*median_point_ptr)));
|
||||
NT val1= *(mpit+split_coord);
|
||||
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it;
|
||||
typename SearchTraits::Cartesian_const_iterator_d mpit = construct_it((*(*median_point_ptr)));
|
||||
FT val1= *(mpit+split_coord);
|
||||
median_point_ptr++;
|
||||
mpit = construct_it((*(*median_point_ptr)));
|
||||
NT val2= *(mpit+split_coord);
|
||||
FT val2= *(mpit+split_coord);
|
||||
|
||||
|
||||
|
||||
return (val1+val2)/NT(2);
|
||||
return (val1+val2)/FT(2);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
16
Packages/Spatial_searching/include/CGAL/Kd_tree_traits_point.h → Packages/Spatial_searching/include/CGAL/Search_traits.h
Executable file → Normal file
16
Packages/Spatial_searching/include/CGAL/Kd_tree_traits_point.h → Packages/Spatial_searching/include/CGAL/Search_traits.h
Executable file → Normal file
|
|
@ -11,7 +11,7 @@
|
|||
// release :
|
||||
// release_date :
|
||||
//
|
||||
// file : include/CGAL/Kd_tree_traits_point.h
|
||||
// file : include/CGAL/Search_traits.h
|
||||
// package : ASPAS
|
||||
// revision : 3.0
|
||||
// revision_date : 2003/07/10
|
||||
|
|
@ -28,17 +28,17 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
template <class NT_, class Point_, class CartesianCoordinateIterator, class ConstructCartesianCoordinateIterator>
|
||||
class Kd_tree_traits_point {
|
||||
template <class FT_, class Point, class CartesianCoordinateIterator, class ConstructCartesianCoordinateIterator>
|
||||
class Search_traits {
|
||||
|
||||
public:
|
||||
typedef CartesianCoordinateIterator Cartesian_const_iterator;
|
||||
typedef ConstructCartesianCoordinateIterator Construct_cartesian_const_iterator;
|
||||
typedef Point_ Point;
|
||||
typedef NT_ NT;
|
||||
typedef CartesianCoordinateIterator Cartesian_const_iterator_d;
|
||||
typedef ConstructCartesianCoordinateIterator Construct_cartesian_const_iterator_d;
|
||||
typedef Point Point_d;
|
||||
typedef FT_ FT;
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // namespace CGAL
|
||||
#endif // KD_TREE_TRAITS_POINT_H
|
||||
#endif // KD_TREE_TRAITS_POINT_H
|
||||
18
Packages/Spatial_searching/include/CGAL/Kd_tree_traits_point_2.h → Packages/Spatial_searching/include/CGAL/Search_traits_2.h
Executable file → Normal file
18
Packages/Spatial_searching/include/CGAL/Kd_tree_traits_point_2.h → Packages/Spatial_searching/include/CGAL/Search_traits_2.h
Executable file → Normal file
|
|
@ -11,7 +11,7 @@
|
|||
// release :
|
||||
// release_date :
|
||||
//
|
||||
// file : include/CGAL/Kd_tree_traits_point_2.h
|
||||
// file : include/CGAL/Search_traits_2.h
|
||||
// package : ASPAS
|
||||
// revision : 3.0
|
||||
// revision_date : 2003/07/10
|
||||
|
|
@ -22,23 +22,23 @@
|
|||
// ======================================================================
|
||||
|
||||
|
||||
#ifndef CGAL_KD_TREE_TRAITS_POINT_2_H
|
||||
#define CGAL_KD_TREE_TRAITS_POINT_2_H
|
||||
#ifndef CGAL_SEARCH_TRAITS_2_H
|
||||
#define CGAL_SEARCH_TRAITS_2_H
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
|
||||
template <class K >
|
||||
|
||||
class Kd_tree_traits_point_2 {
|
||||
class Search_traits_2 {
|
||||
|
||||
public:
|
||||
typedef typename K::Point_2 Point;
|
||||
typedef typename K::Cartesian_const_iterator_2 Cartesian_const_iterator;
|
||||
typedef typename K::Construct_cartesian_const_iterator_2 Construct_cartesian_const_iterator;
|
||||
typedef typename K::FT NT;
|
||||
typedef typename K::Point_2 Point_d;
|
||||
typedef typename K::Cartesian_const_iterator_2 Cartesian_const_iterator_d;
|
||||
typedef typename K::Construct_cartesian_const_iterator_2 Construct_cartesian_const_iterator_d;
|
||||
typedef typename K::FT FT;
|
||||
};
|
||||
|
||||
|
||||
} // namespace CGAL
|
||||
#endif // KD_TREE_TRAITS_POINT_2_H
|
||||
#endif // CGAL_SEARCH_TRAITS_2_H
|
||||
18
Packages/Spatial_searching/include/CGAL/Kd_tree_traits_point_3.h → Packages/Spatial_searching/include/CGAL/Search_traits_3.h
Executable file → Normal file
18
Packages/Spatial_searching/include/CGAL/Kd_tree_traits_point_3.h → Packages/Spatial_searching/include/CGAL/Search_traits_3.h
Executable file → Normal file
|
|
@ -11,7 +11,7 @@
|
|||
// release :
|
||||
// release_date :
|
||||
//
|
||||
// file : include/CGAL/Kd_tree_traits_point_3.h
|
||||
// file : include/CGAL/Search_traits_3.h
|
||||
// package : ASPAS
|
||||
// revision : 3.0
|
||||
// revision_date : 2003/07/10
|
||||
|
|
@ -22,25 +22,25 @@
|
|||
// ======================================================================
|
||||
|
||||
|
||||
#ifndef CGAL_KD_TREE_TRAITS_POINT_3_H
|
||||
#define CGAL_KD_TREE_TRAITS_POINT_3_H
|
||||
#ifndef CGAL_SEARCH_TRAITS_3_H
|
||||
#define CGAL_SEARCH_TRAITS_3_H
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
|
||||
template <class K>
|
||||
|
||||
class Kd_tree_traits_point_3 {
|
||||
class Search_traits_3 {
|
||||
|
||||
public:
|
||||
|
||||
typedef typename K::Cartesian_const_iterator_3 Cartesian_const_iterator;
|
||||
typedef typename K::Construct_cartesian_const_iterator_3 Construct_cartesian_const_iterator;
|
||||
typedef typename K::Point_3 Point;
|
||||
typedef typename K::FT NT;
|
||||
typedef typename K::Cartesian_const_iterator_3 Cartesian_const_iterator_d;
|
||||
typedef typename K::Construct_cartesian_const_iterator_3 Construct_cartesian_const_iterator_d;
|
||||
typedef typename K::Point_3 Point_d;
|
||||
typedef typename K::FT FT;
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // namespace CGAL
|
||||
#endif // KD_TREE_TRAITS_POINT_3_H
|
||||
#endif // SEARCH_TRAITS_3_H
|
||||
16
Packages/Spatial_searching/include/CGAL/Kd_tree_traits_point_d.h → Packages/Spatial_searching/include/CGAL/Search_traits_d.h
Executable file → Normal file
16
Packages/Spatial_searching/include/CGAL/Kd_tree_traits_point_d.h → Packages/Spatial_searching/include/CGAL/Search_traits_d.h
Executable file → Normal file
|
|
@ -22,22 +22,22 @@
|
|||
// ======================================================================
|
||||
|
||||
|
||||
#ifndef CGAL_KD_TREE_TRAITS_POINT_D_H
|
||||
#define CGAL_KD_TREE_TRAITS_POINT_D_H
|
||||
#ifndef CGAL_SEARCH_TRAITS_D_H
|
||||
#define CGAL_SEARCH_TRAITS_D_H
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
template <class K>
|
||||
class Kd_tree_traits_point_d {
|
||||
class Search_traits_d {
|
||||
|
||||
public:
|
||||
typedef typename K::Cartesian_const_iterator_d Cartesian_const_iterator;
|
||||
typedef typename K::Construct_Cartesian_const_iterator_d Construct_cartesian_const_iterator;
|
||||
typedef typename K::Point_d Point;
|
||||
typedef typename K::FT NT;
|
||||
typedef typename K::Cartesian_const_iterator_d Cartesian_const_iterator_d;
|
||||
typedef typename K::Construct_Cartesian_const_iterator_d Construct_cartesian_const_iterator_d;
|
||||
typedef typename K::Point_d Point_d;
|
||||
typedef typename K::FT FT;
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // namespace CGAL
|
||||
#endif // KD_TREE_TRAITS_POINT_D_H
|
||||
#endif // CGAL_SEARCH_TRAITS_D_H
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
// Defines rules used for constructing a split node. That is, it implements,
|
||||
// in several ways, the concept
|
||||
// Boxtree_splitter<NT>.
|
||||
// Boxtree_splitter<FT>.
|
||||
|
||||
#ifndef CGAL_SPLITTERS_H
|
||||
#define CGAL_SPLITTERS_H
|
||||
|
|
@ -31,20 +31,20 @@
|
|||
#include <CGAL/Plane_separator.h>
|
||||
namespace CGAL {
|
||||
|
||||
template <class NT>
|
||||
template <class FT>
|
||||
class Splitter_base {
|
||||
private:
|
||||
unsigned int the_bucket_size;
|
||||
NT the_aspect_ratio;
|
||||
FT the_aspect_ratio;
|
||||
|
||||
public:
|
||||
Splitter_base(unsigned int bucket_size = 3,
|
||||
NT aspect_ratio = NT(3))
|
||||
FT aspect_ratio = FT(3))
|
||||
: the_bucket_size(bucket_size),
|
||||
the_aspect_ratio(aspect_ratio)
|
||||
{}
|
||||
|
||||
NT
|
||||
FT
|
||||
aspect_ratio() const {
|
||||
return the_aspect_ratio;
|
||||
}
|
||||
|
|
@ -57,15 +57,15 @@ public:
|
|||
};
|
||||
|
||||
|
||||
template <class GeomTraits, class Container_=Point_container<GeomTraits>,
|
||||
class Separator_=Plane_separator<typename GeomTraits::NT> >
|
||||
template <class SearchTraits, class Container_=Point_container<SearchTraits>,
|
||||
class Separator_=Plane_separator<typename SearchTraits::FT> >
|
||||
class Median_of_max_spread
|
||||
: public Splitter_base<typename GeomTraits::NT>
|
||||
: public Splitter_base<typename SearchTraits::FT>
|
||||
{
|
||||
|
||||
typedef Splitter_base<typename GeomTraits::NT> Base;
|
||||
typedef Splitter_base<typename SearchTraits::FT> Base;
|
||||
public:
|
||||
typedef typename GeomTraits::NT NT;
|
||||
typedef typename SearchTraits::FT FT;
|
||||
typedef Container_ Container;
|
||||
typedef Separator_ Separator;
|
||||
|
||||
|
|
@ -80,20 +80,20 @@ public:
|
|||
void operator() (Separator& sep,
|
||||
Container& c0,
|
||||
Container& c1) {
|
||||
sep=Separator(c0.max_tight_span_coord(),NT(0));
|
||||
sep=Separator(c0.max_tight_span_coord(),FT(0));
|
||||
sep.set_cutting_value(c0.median(sep.cutting_dimension()));
|
||||
c0.split(c1,sep,true);
|
||||
}
|
||||
};
|
||||
|
||||
template <class GeomTraits, class Container_=Point_container<GeomTraits>,
|
||||
class Separator_=Plane_separator<typename GeomTraits::NT> >
|
||||
template <class SearchTraits, class Container_=Point_container<SearchTraits>,
|
||||
class Separator_=Plane_separator<typename SearchTraits::FT> >
|
||||
class Fair
|
||||
: public Splitter_base<typename GeomTraits::NT> {
|
||||
: public Splitter_base<typename SearchTraits::FT> {
|
||||
|
||||
typedef Splitter_base<typename GeomTraits::NT> Base;
|
||||
typedef Splitter_base<typename SearchTraits::FT> Base;
|
||||
public:
|
||||
typedef typename GeomTraits::NT NT;
|
||||
typedef typename SearchTraits::FT FT;
|
||||
typedef Container_ Container;
|
||||
typedef Separator_ Separator;
|
||||
|
||||
|
|
@ -102,7 +102,7 @@ public:
|
|||
{}
|
||||
|
||||
Fair(unsigned int bucket_size,
|
||||
NT aspect_ratio=NT(3))
|
||||
FT aspect_ratio=FT(3))
|
||||
: Base(bucket_size, aspect_ratio)
|
||||
{}
|
||||
|
||||
|
|
@ -110,22 +110,22 @@ public:
|
|||
Container& c1) {
|
||||
// find legal cut with max spread
|
||||
sep=Separator(c0.max_tight_span_coord_balanced(aspect_ratio()),
|
||||
NT(0));
|
||||
FT(0));
|
||||
sep.set_cutting_value(c0.balanced_fair(sep.cutting_dimension(),
|
||||
aspect_ratio()));
|
||||
c0.split(c1,sep);
|
||||
}
|
||||
};
|
||||
|
||||
template <class GeomTraits, class Container_=Point_container<GeomTraits>,
|
||||
class Separator_=Plane_separator<typename GeomTraits::NT> >
|
||||
template <class SearchTraits, class Container_=Point_container<SearchTraits>,
|
||||
class Separator_=Plane_separator<typename SearchTraits::FT> >
|
||||
class Sliding_fair
|
||||
: public Splitter_base<typename GeomTraits::NT> {
|
||||
: public Splitter_base<typename SearchTraits::FT> {
|
||||
|
||||
typedef Splitter_base<typename GeomTraits::NT> Base;
|
||||
typedef Splitter_base<typename SearchTraits::FT> Base;
|
||||
|
||||
public:
|
||||
typedef typename GeomTraits::NT NT;
|
||||
typedef typename SearchTraits::FT FT;
|
||||
typedef Container_ Container;
|
||||
typedef Separator_ Separator;
|
||||
|
||||
|
|
@ -134,7 +134,7 @@ public:
|
|||
{}
|
||||
|
||||
Sliding_fair(unsigned int bucket_size,
|
||||
NT aspect_ratio=NT(3))
|
||||
FT aspect_ratio=FT(3))
|
||||
: Base(bucket_size, aspect_ratio)
|
||||
{}
|
||||
|
||||
|
|
@ -143,7 +143,7 @@ public:
|
|||
// find legal cut with max spread
|
||||
|
||||
sep=Separator(c0.max_tight_span_coord_balanced(aspect_ratio()),
|
||||
NT(0));
|
||||
FT(0));
|
||||
|
||||
sep.set_cutting_value(c0.balanced_sliding_fair(sep.cutting_dimension(),
|
||||
aspect_ratio()));
|
||||
|
|
@ -152,15 +152,15 @@ public:
|
|||
};
|
||||
|
||||
|
||||
template <class GeomTraits, class Container_=Point_container<GeomTraits>,
|
||||
class Separator_=Plane_separator<typename GeomTraits::NT> >
|
||||
template <class SearchTraits, class Container_=Point_container<SearchTraits>,
|
||||
class Separator_=Plane_separator<typename SearchTraits::FT> >
|
||||
class Sliding_midpoint
|
||||
: public Splitter_base<typename GeomTraits::NT> {
|
||||
: public Splitter_base<typename SearchTraits::FT> {
|
||||
|
||||
typedef Splitter_base<typename GeomTraits::NT> Base;
|
||||
typedef Splitter_base<typename SearchTraits::FT> Base;
|
||||
|
||||
public:
|
||||
typedef typename GeomTraits::NT NT;
|
||||
typedef typename SearchTraits::FT FT;
|
||||
typedef Container_ Container;
|
||||
typedef Separator_ Separator;
|
||||
|
||||
|
|
@ -176,10 +176,10 @@ public:
|
|||
Container& c1)
|
||||
{
|
||||
sep=Separator(c0.max_span_coord(),
|
||||
(c0.max_span_upper() + c0.max_span_lower())/NT(2));
|
||||
NT max_span_lower =
|
||||
(c0.max_span_upper() + c0.max_span_lower())/FT(2));
|
||||
FT max_span_lower =
|
||||
c0.tight_bounding_box().min_coord(c0.max_span_coord());
|
||||
NT max_span_upper =
|
||||
FT max_span_upper =
|
||||
c0.tight_bounding_box().max_coord(c0.max_span_coord());
|
||||
if (max_span_upper <= sep.cutting_value()) {
|
||||
sep.set_cutting_value(max_span_upper);
|
||||
|
|
@ -191,15 +191,15 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
template <class GeomTraits, class Container_=Point_container<GeomTraits>,
|
||||
class Separator_=Plane_separator<typename GeomTraits::NT> >
|
||||
template <class SearchTraits, class Container_=Point_container<SearchTraits>,
|
||||
class Separator_=Plane_separator<typename SearchTraits::FT> >
|
||||
class Median_of_rectangle
|
||||
: public Splitter_base<typename GeomTraits::NT> {
|
||||
: public Splitter_base<typename SearchTraits::FT> {
|
||||
|
||||
typedef Splitter_base<typename GeomTraits::NT> Base;
|
||||
typedef Splitter_base<typename SearchTraits::FT> Base;
|
||||
|
||||
public:
|
||||
typedef typename GeomTraits::NT NT;
|
||||
typedef typename SearchTraits::FT FT;
|
||||
typedef Container_ Container;
|
||||
typedef Separator_ Separator;
|
||||
|
||||
|
|
@ -215,21 +215,21 @@ public:
|
|||
void operator() (Separator& sep, Container& c0,
|
||||
Container& c1)
|
||||
{
|
||||
sep=Separator(c0.max_span_coord(),NT(0));
|
||||
sep=Separator(c0.max_span_coord(),FT(0));
|
||||
sep.set_cutting_value(c0.median(sep.cutting_dimension()));
|
||||
c0.split(c1,sep,true);
|
||||
}
|
||||
};
|
||||
|
||||
template <class GeomTraits, class Container_=Point_container<GeomTraits>,
|
||||
class Separator_=Plane_separator<typename GeomTraits::NT> >
|
||||
template <class SearchTraits, class Container_=Point_container<SearchTraits>,
|
||||
class Separator_=Plane_separator<typename SearchTraits::FT> >
|
||||
class Midpoint_of_max_spread
|
||||
: public Splitter_base<typename GeomTraits::NT> {
|
||||
: public Splitter_base<typename SearchTraits::FT> {
|
||||
|
||||
typedef Splitter_base<typename GeomTraits::NT> Base;
|
||||
typedef Splitter_base<typename SearchTraits::FT> Base;
|
||||
|
||||
public:
|
||||
typedef typename GeomTraits::NT NT;
|
||||
typedef typename SearchTraits::FT FT;
|
||||
typedef Container_ Container;
|
||||
typedef Separator_ Separator;
|
||||
|
||||
|
|
@ -246,19 +246,19 @@ public:
|
|||
Container& c1)
|
||||
{
|
||||
sep= Separator(c0.max_tight_span_coord(),
|
||||
(c0.max_tight_span_upper() + c0.max_tight_span_lower())/NT(2));
|
||||
(c0.max_tight_span_upper() + c0.max_tight_span_lower())/FT(2));
|
||||
c0.split(c1,sep);
|
||||
}
|
||||
};
|
||||
|
||||
template <class GeomTraits, class Container_=Point_container<GeomTraits>,
|
||||
class Separator_=Plane_separator<typename GeomTraits::NT> >
|
||||
template <class SearchTraits, class Container_=Point_container<SearchTraits>,
|
||||
class Separator_=Plane_separator<typename SearchTraits::FT> >
|
||||
class Midpoint_of_rectangle
|
||||
: public Splitter_base<typename GeomTraits::NT> {
|
||||
: public Splitter_base<typename SearchTraits::FT> {
|
||||
|
||||
typedef Splitter_base<typename GeomTraits::NT> Base;
|
||||
typedef Splitter_base<typename SearchTraits::FT> Base;
|
||||
public:
|
||||
typedef typename GeomTraits::NT NT;
|
||||
typedef typename SearchTraits::FT FT;
|
||||
typedef Container_ Container;
|
||||
typedef Separator_ Separator;
|
||||
|
||||
|
|
@ -275,7 +275,7 @@ public:
|
|||
Container& c1)
|
||||
{
|
||||
sep = Separator(c0.max_span_coord(),
|
||||
(c0.max_span_upper() + c0.max_span_lower())/NT(2));
|
||||
(c0.max_span_upper() + c0.max_span_lower())/FT(2));
|
||||
c0.split(c1,sep);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,19 +31,19 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
template <class GeomTraits>
|
||||
template <class SearchTraits>
|
||||
class Weighted_Minkowski_distance {
|
||||
|
||||
public:
|
||||
|
||||
typedef typename GeomTraits::Point Point;
|
||||
typedef typename GeomTraits::NT NT;
|
||||
typedef std::vector<NT> Weight_vector;
|
||||
typedef typename SearchTraits::Point_d Point_d;
|
||||
typedef typename SearchTraits::FT FT;
|
||||
typedef std::vector<FT> Weight_vector;
|
||||
|
||||
private:
|
||||
|
||||
typedef typename GeomTraits::Cartesian_const_iterator Coord_iterator;
|
||||
NT power;
|
||||
typedef typename SearchTraits::Cartesian_const_iterator_d Coord_iterator;
|
||||
FT power;
|
||||
|
||||
Weight_vector the_weights;
|
||||
|
||||
|
|
@ -59,51 +59,51 @@ namespace CGAL {
|
|||
: power(2)
|
||||
{
|
||||
the_weights.reserve(d);
|
||||
for (unsigned int i = 0; i < d; ++i) the_weights[i]=NT(1);
|
||||
for (unsigned int i = 0; i < d; ++i) the_weights[i]=FT(1);
|
||||
}
|
||||
|
||||
//default copy constructor and destructor
|
||||
|
||||
|
||||
Weighted_Minkowski_distance (NT pow, int dim,
|
||||
Weighted_Minkowski_distance (FT pow, int dim,
|
||||
const Weight_vector& weights)
|
||||
: power(pow)
|
||||
{
|
||||
assert(power >= NT(0));
|
||||
assert(power >= FT(0));
|
||||
assert(dim==weights.size());
|
||||
for (unsigned int i = 0; i < weights.size(); ++i)
|
||||
assert(weights[i]>=NT(0));
|
||||
assert(weights[i]>=FT(0));
|
||||
the_weights.resize(weights.size());
|
||||
the_weights = weights;
|
||||
}
|
||||
|
||||
template <class InputIterator>
|
||||
Weighted_Minkowski_distance (NT pow, int dim,
|
||||
Weighted_Minkowski_distance (FT pow, int dim,
|
||||
InputIterator begin, InputIterator end)
|
||||
: power(pow)
|
||||
{
|
||||
assert(power >= NT(0));
|
||||
assert(power >= FT(0));
|
||||
the_weights.resize(dim);
|
||||
std::copy(begin, end, the_weights.begin());
|
||||
for (unsigned int i = 0; i < dim; ++i){
|
||||
the_weights[i] = *begin;
|
||||
++begin;
|
||||
assert(the_weights[i]>=NT(0));
|
||||
assert(the_weights[i]>=FT(0));
|
||||
}
|
||||
assert(begin == end);
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
NT
|
||||
distance(const Point& q, const Point& p)
|
||||
FT
|
||||
transformed_distance(const Point_d& q, const Point_d& p)
|
||||
{
|
||||
NT distance = NT(0);
|
||||
typename GeomTraits::Construct_cartesian_const_iterator construct_it;
|
||||
FT distance = FT(0);
|
||||
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it;
|
||||
Coord_iterator qit = construct_it(q),
|
||||
qe = construct_it(q,1),
|
||||
pit = construct_it(p);
|
||||
if (power == NT(0)) {
|
||||
if (power == FT(0)) {
|
||||
for (unsigned int i = 0; qit != qe; ++qit, ++i)
|
||||
if (the_weights[i] * fabs((*qit) - (*pit)) > distance)
|
||||
distance = the_weights[i] * fabs((*qit)-(*pit));
|
||||
|
|
@ -117,14 +117,14 @@ namespace CGAL {
|
|||
|
||||
|
||||
inline
|
||||
NT
|
||||
min_distance_to_rectangle(const Point& q,
|
||||
const Kd_tree_rectangle<GeomTraits>& r) const
|
||||
FT
|
||||
min_distance_to_rectangle(const Point_d& q,
|
||||
const Kd_tree_rectangle<SearchTraits>& r) const
|
||||
{
|
||||
NT distance = NT(0);
|
||||
typename GeomTraits::Construct_cartesian_const_iterator construct_it;
|
||||
FT distance = FT(0);
|
||||
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it;
|
||||
Coord_iterator qit = construct_it(q), qe = construct_it(q,1);
|
||||
if (power == NT(0))
|
||||
if (power == FT(0))
|
||||
{
|
||||
for (unsigned int i = 0; qit != qe; ++qit, ++i) {
|
||||
if (the_weights[i]*(r.min_coord(i) -
|
||||
|
|
@ -152,17 +152,17 @@ namespace CGAL {
|
|||
}
|
||||
|
||||
inline
|
||||
NT
|
||||
max_distance_to_rectangle(const Point& q,
|
||||
const Kd_tree_rectangle<GeomTraits>& r) const {
|
||||
NT distance=NT(0);
|
||||
typename GeomTraits::Construct_cartesian_const_iterator construct_it;
|
||||
FT
|
||||
max_distance_to_rectangle(const Point_d& q,
|
||||
const Kd_tree_rectangle<SearchTraits>& r) const {
|
||||
FT distance=FT(0);
|
||||
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it;
|
||||
Coord_iterator qit = construct_it(q), qe = construct_it(q,1);
|
||||
if (power == NT(0))
|
||||
if (power == FT(0))
|
||||
{
|
||||
for (unsigned int i = 0; qit != qe; ++qit, ++i) {
|
||||
if ((*qit) >= (r.min_coord(i) +
|
||||
r.max_coord(i))/NT(2.0))
|
||||
r.max_coord(i))/FT(2.0))
|
||||
if (the_weights[i] * ((*qit) -
|
||||
r.min_coord(i)) > distance)
|
||||
distance = the_weights[i] *
|
||||
|
|
@ -177,7 +177,7 @@ namespace CGAL {
|
|||
else
|
||||
{
|
||||
for (unsigned int i = 0; qit != qe; ++qit, ++i) {
|
||||
if ((*qit) <= (r.min_coord(i)+r.max_coord(i))/NT(2.0))
|
||||
if ((*qit) <= (r.min_coord(i)+r.max_coord(i))/FT(2.0))
|
||||
distance += the_weights[i] * pow(r.max_coord(i)-(*qit),power);
|
||||
else
|
||||
distance += the_weights[i] * pow((*qit)-r.min_coord(i),power);
|
||||
|
|
@ -187,12 +187,12 @@ namespace CGAL {
|
|||
}
|
||||
|
||||
inline
|
||||
NT
|
||||
new_distance(NT dist, NT old_off, NT new_off,
|
||||
FT
|
||||
new_distance(FT dist, FT old_off, FT new_off,
|
||||
int cutting_dimension) const
|
||||
{
|
||||
NT new_dist;
|
||||
if (power == NT(0))
|
||||
FT new_dist;
|
||||
if (power == FT(0))
|
||||
{
|
||||
if (the_weights[cutting_dimension]*fabs(new_off)
|
||||
> dist)
|
||||
|
|
@ -209,19 +209,19 @@ namespace CGAL {
|
|||
}
|
||||
|
||||
inline
|
||||
NT
|
||||
transformed_distance(NT d) const
|
||||
FT
|
||||
transformed_distance(FT d) const
|
||||
{
|
||||
if (power <= NT(0)) return d;
|
||||
if (power <= FT(0)) return d;
|
||||
else return pow(d,power);
|
||||
|
||||
}
|
||||
|
||||
inline
|
||||
NT
|
||||
inverse_of_transformed_distance(NT d) const
|
||||
FT
|
||||
inverse_of_transformed_distance(FT d) const
|
||||
{
|
||||
if (power <= NT(0)) return d;
|
||||
if (power <= FT(0)) return d;
|
||||
else return pow(d,1/power);
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue