mirror of https://github.com/CGAL/cgal
fixed copyright headers
This commit is contained in:
parent
1c355ef42a
commit
85894658ef
|
|
@ -1,5 +1,4 @@
|
||||||
// Copyright (c) 2001 Tel-Aviv University (Israel).
|
// Copyright (c) 2001,2009,2014 Tel-Aviv University (Israel), Max-Planck-Institute Saarbruecken (Germany).
|
||||||
// 2009,2014 Max-Planck-Institute Saarbruecken (Germany).
|
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
@ -15,9 +14,9 @@
|
||||||
//
|
//
|
||||||
// $URL$
|
// $URL$
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
|
||||||
//
|
//
|
||||||
// author(s) : Eli Packer <elip@post.tau.ac.il>,
|
//
|
||||||
|
// author(s) : Eli Packer <elip@post.tau.ac.il>,
|
||||||
// Waqar Khan <wkhan@mpi-inf.mpg.de>
|
// Waqar Khan <wkhan@mpi-inf.mpg.de>
|
||||||
|
|
||||||
#ifndef CGAL_SNAP_ROUNDING_2_TRAITS_H
|
#ifndef CGAL_SNAP_ROUNDING_2_TRAITS_H
|
||||||
|
|
@ -58,7 +57,7 @@ public: // otherwise Segment_data cannot access the types
|
||||||
typedef CGAL::Arr_segment_traits_2<Base_kernel> Base_traits;
|
typedef CGAL::Arr_segment_traits_2<Base_kernel> Base_traits;
|
||||||
typedef typename Base_traits::Compare_x_2 Compare_x_2;
|
typedef typename Base_traits::Compare_x_2 Compare_x_2;
|
||||||
typedef CGAL::To_double<NT> To_double;
|
typedef CGAL::To_double<NT> To_double;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*! Functor */
|
/*! Functor */
|
||||||
class Snap_2 {
|
class Snap_2 {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
// Copyright (c) 2002,2011 Utrecht University (The Netherlands).
|
// Copyright (c) 2002,2011,2014 Utrecht University (The Netherlands), Max-Planck-Institute Saarbruecken (Germany).
|
||||||
// 2009,2014 Max-Planck-Institute Saarbruecken (Germany)
|
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
@ -15,8 +14,8 @@
|
||||||
//
|
//
|
||||||
// $URL$
|
// $URL$
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
//
|
||||||
// Author(s) : Hans Tangelder (<hanst@cs.uu.nl>),
|
// Author(s) : Hans Tangelder (<hanst@cs.uu.nl>),
|
||||||
// : Waqar Khan <wkhan@mpi-inf.mpg.de>
|
// : Waqar Khan <wkhan@mpi-inf.mpg.de>
|
||||||
|
|
||||||
#ifndef CGAL_KD_TREE_H
|
#ifndef CGAL_KD_TREE_H
|
||||||
|
|
@ -46,7 +45,7 @@ public:
|
||||||
typedef Splitter_ Splitter;
|
typedef Splitter_ Splitter;
|
||||||
typedef typename SearchTraits::Point_d Point_d;
|
typedef typename SearchTraits::Point_d Point_d;
|
||||||
typedef typename Splitter::Container Point_container;
|
typedef typename Splitter::Container Point_container;
|
||||||
|
|
||||||
typedef typename SearchTraits::FT FT;
|
typedef typename SearchTraits::FT FT;
|
||||||
typedef Kd_tree_node<SearchTraits, Splitter, UseExtendedNode > Node;
|
typedef Kd_tree_node<SearchTraits, Splitter, UseExtendedNode > Node;
|
||||||
typedef Kd_tree<SearchTraits, Splitter> Tree;
|
typedef Kd_tree<SearchTraits, Splitter> Tree;
|
||||||
|
|
@ -59,7 +58,7 @@ public:
|
||||||
typedef typename Splitter::Separator Separator;
|
typedef typename Splitter::Separator Separator;
|
||||||
typedef typename std::vector<Point_d>::const_iterator iterator;
|
typedef typename std::vector<Point_d>::const_iterator iterator;
|
||||||
typedef typename std::vector<Point_d>::const_iterator const_iterator;
|
typedef typename std::vector<Point_d>::const_iterator const_iterator;
|
||||||
|
|
||||||
typedef typename std::vector<Point_d>::size_type size_type;
|
typedef typename std::vector<Point_d>::size_type size_type;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -75,7 +74,7 @@ private:
|
||||||
// Instead of storing the points in arrays in the Kd_tree_node
|
// Instead of storing the points in arrays in the Kd_tree_node
|
||||||
// we put all the data in a vector in the Kd_tree.
|
// we put all the data in a vector in the Kd_tree.
|
||||||
// and we only store an iterator range in the Kd_tree_node.
|
// and we only store an iterator range in the Kd_tree_node.
|
||||||
//
|
//
|
||||||
std::vector<const Point_d*> data;
|
std::vector<const Point_d*> data;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -95,7 +94,7 @@ private:
|
||||||
// the allocation of the nodes.
|
// the allocation of the nodes.
|
||||||
|
|
||||||
// The leaf node
|
// The leaf node
|
||||||
Node_handle
|
Node_handle
|
||||||
create_leaf_node(Point_container& c)
|
create_leaf_node(Point_container& c)
|
||||||
{
|
{
|
||||||
Node_handle nh = nodes.emplace(static_cast<unsigned int>(c.size()), Node::LEAF);
|
Node_handle nh = nodes.emplace(static_cast<unsigned int>(c.size()), Node::LEAF);
|
||||||
|
|
@ -104,40 +103,40 @@ private:
|
||||||
return nh;
|
return nh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// The internal node
|
// The internal node
|
||||||
|
|
||||||
Node_handle
|
Node_handle
|
||||||
create_internal_node(Point_container& c, const Tag_true&)
|
create_internal_node(Point_container& c, const Tag_true&)
|
||||||
{
|
{
|
||||||
return create_internal_node_use_extension(c);
|
return create_internal_node_use_extension(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
Node_handle
|
Node_handle
|
||||||
create_internal_node(Point_container& c, const Tag_false&)
|
create_internal_node(Point_container& c, const Tag_false&)
|
||||||
{
|
{
|
||||||
return create_internal_node(c);
|
return create_internal_node(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: Similiar to the leaf_init function above, a part of the code should be
|
// TODO: Similiar to the leaf_init function above, a part of the code should be
|
||||||
// moved to a the class Kd_tree_node.
|
// moved to a the class Kd_tree_node.
|
||||||
// It is not proper yet, but the goal was to see if there is
|
// It is not proper yet, but the goal was to see if there is
|
||||||
// a potential performance gain through the Compact_container
|
// a potential performance gain through the Compact_container
|
||||||
Node_handle
|
Node_handle
|
||||||
create_internal_node_use_extension(Point_container& c)
|
create_internal_node_use_extension(Point_container& c)
|
||||||
{
|
{
|
||||||
Node_handle nh = nodes.emplace(Node::EXTENDED_INTERNAL);
|
Node_handle nh = nodes.emplace(Node::EXTENDED_INTERNAL);
|
||||||
|
|
||||||
Point_container c_low(c.dimension(),traits_);
|
Point_container c_low(c.dimension(),traits_);
|
||||||
split(nh->separator(), c, c_low);
|
split(nh->separator(), c, c_low);
|
||||||
|
|
||||||
int cd = nh->separator().cutting_dimension();
|
int cd = nh->separator().cutting_dimension();
|
||||||
|
|
||||||
nh->low_val = c_low.bounding_box().min_coord(cd);
|
nh->low_val = c_low.bounding_box().min_coord(cd);
|
||||||
nh->high_val = c.bounding_box().max_coord(cd);
|
nh->high_val = c.bounding_box().max_coord(cd);
|
||||||
|
|
||||||
CGAL_assertion(nh->separator().cutting_value() >= nh->low_val);
|
CGAL_assertion(nh->separator().cutting_value() >= nh->low_val);
|
||||||
CGAL_assertion(nh->separator().cutting_value() <= nh->high_val);
|
CGAL_assertion(nh->separator().cutting_value() <= nh->high_val);
|
||||||
|
|
||||||
|
|
@ -151,21 +150,21 @@ private:
|
||||||
}else{
|
}else{
|
||||||
nh->upper_ch = create_leaf_node(c);
|
nh->upper_ch = create_leaf_node(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nh;
|
return nh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Note also that I duplicated the code to get rid if the if's for
|
// Note also that I duplicated the code to get rid if the if's for
|
||||||
// the boolean use_extension which was constant over the construction
|
// the boolean use_extension which was constant over the construction
|
||||||
Node_handle
|
Node_handle
|
||||||
create_internal_node(Point_container& c)
|
create_internal_node(Point_container& c)
|
||||||
{
|
{
|
||||||
Node_handle nh = nodes.emplace(Node::INTERNAL);
|
Node_handle nh = nodes.emplace(Node::INTERNAL);
|
||||||
|
|
||||||
Point_container c_low(c.dimension(),traits_);
|
Point_container c_low(c.dimension(),traits_);
|
||||||
split(nh->separator(), c, c_low);
|
split(nh->separator(), c, c_low);
|
||||||
|
|
||||||
if (c_low.size() > split.bucket_size()){
|
if (c_low.size() > split.bucket_size()){
|
||||||
nh->lower_ch = create_internal_node(c_low);
|
nh->lower_ch = create_internal_node(c_low);
|
||||||
}else{
|
}else{
|
||||||
|
|
@ -186,11 +185,11 @@ public:
|
||||||
Kd_tree(Splitter s = Splitter(),const SearchTraits traits=SearchTraits())
|
Kd_tree(Splitter s = Splitter(),const SearchTraits traits=SearchTraits())
|
||||||
: traits_(traits),split(s), built_(false)
|
: traits_(traits),split(s), built_(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template <class InputIterator>
|
template <class InputIterator>
|
||||||
Kd_tree(InputIterator first, InputIterator beyond,
|
Kd_tree(InputIterator first, InputIterator beyond,
|
||||||
Splitter s = Splitter(),const SearchTraits traits=SearchTraits())
|
Splitter s = Splitter(),const SearchTraits traits=SearchTraits())
|
||||||
: traits_(traits),split(s), built_(false)
|
: traits_(traits),split(s), built_(false)
|
||||||
{
|
{
|
||||||
pts.insert(pts.end(), first, beyond);
|
pts.insert(pts.end(), first, beyond);
|
||||||
}
|
}
|
||||||
|
|
@ -198,13 +197,13 @@ public:
|
||||||
bool empty() const {
|
bool empty() const {
|
||||||
return pts.empty();
|
return pts.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
build()
|
build()
|
||||||
{
|
{
|
||||||
const Point_d& p = *pts.begin();
|
const Point_d& p = *pts.begin();
|
||||||
typename SearchTraits::Construct_cartesian_const_iterator_d ccci=traits_.construct_cartesian_const_iterator_d_object();
|
typename SearchTraits::Construct_cartesian_const_iterator_d ccci=traits_.construct_cartesian_const_iterator_d_object();
|
||||||
int dim = static_cast<int>(std::distance(ccci(p), ccci(p,0)));
|
int dim = static_cast<int>(std::distance(ccci(p), ccci(p,0)));
|
||||||
|
|
||||||
data.reserve(pts.size());
|
data.reserve(pts.size());
|
||||||
for(unsigned int i = 0; i < pts.size(); i++){
|
for(unsigned int i = 0; i < pts.size(); i++){
|
||||||
|
|
@ -215,12 +214,12 @@ public:
|
||||||
if (c.size() <= split.bucket_size()){
|
if (c.size() <= split.bucket_size()){
|
||||||
tree_root = create_leaf_node(c);
|
tree_root = create_leaf_node(c);
|
||||||
}else {
|
}else {
|
||||||
tree_root = create_internal_node(c, UseExtendedNode());
|
tree_root = create_internal_node(c, UseExtendedNode());
|
||||||
}
|
}
|
||||||
built_ = true;
|
built_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//any call to this function is for the moment not threadsafe
|
//any call to this function is for the moment not threadsafe
|
||||||
void const_build() const {
|
void const_build() const {
|
||||||
#ifdef CGAL_HAS_THREADS
|
#ifdef CGAL_HAS_THREADS
|
||||||
|
|
@ -231,7 +230,7 @@ private:
|
||||||
const_cast<Self*>(this)->build(); //THIS IS NOT THREADSAFE
|
const_cast<Self*>(this)->build(); //THIS IS NOT THREADSAFE
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool is_built() const
|
bool is_built() const
|
||||||
{
|
{
|
||||||
return built_;
|
return built_;
|
||||||
|
|
@ -246,22 +245,22 @@ public:
|
||||||
built_ = false;
|
built_ = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
invalidate_built();
|
invalidate_built();
|
||||||
pts.clear();
|
pts.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
insert(const Point_d& p)
|
insert(const Point_d& p)
|
||||||
{
|
{
|
||||||
invalidate_built();
|
invalidate_built();
|
||||||
pts.push_back(p);
|
pts.push_back(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class InputIterator>
|
template <class InputIterator>
|
||||||
void
|
void
|
||||||
insert(InputIterator first, InputIterator beyond)
|
insert(InputIterator first, InputIterator beyond)
|
||||||
{
|
{
|
||||||
invalidate_built();
|
invalidate_built();
|
||||||
|
|
@ -276,11 +275,11 @@ public:
|
||||||
|
|
||||||
|
|
||||||
template <class OutputIterator, class FuzzyQueryItem>
|
template <class OutputIterator, class FuzzyQueryItem>
|
||||||
OutputIterator
|
OutputIterator
|
||||||
search(OutputIterator it, const FuzzyQueryItem& q) const
|
search(OutputIterator it, const FuzzyQueryItem& q) const
|
||||||
{
|
{
|
||||||
if(! pts.empty()){
|
if(! pts.empty()){
|
||||||
|
|
||||||
if(! is_built()){
|
if(! is_built()){
|
||||||
const_build();
|
const_build();
|
||||||
}
|
}
|
||||||
|
|
@ -298,27 +297,27 @@ public:
|
||||||
|
|
||||||
|
|
||||||
const SearchTraits&
|
const SearchTraits&
|
||||||
traits() const
|
traits() const
|
||||||
{
|
{
|
||||||
return traits_;
|
return traits_;
|
||||||
}
|
}
|
||||||
|
|
||||||
Node_const_handle
|
Node_const_handle
|
||||||
root() const
|
root() const
|
||||||
{
|
{
|
||||||
if(! is_built()){
|
if(! is_built()){
|
||||||
const_build();
|
const_build();
|
||||||
}
|
}
|
||||||
return tree_root;
|
return tree_root;
|
||||||
}
|
}
|
||||||
|
|
||||||
Node_handle
|
Node_handle
|
||||||
root()
|
root()
|
||||||
{
|
{
|
||||||
if(! is_built()){
|
if(! is_built()){
|
||||||
build();
|
build();
|
||||||
}
|
}
|
||||||
return tree_root;
|
return tree_root;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -331,12 +330,12 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
const Kd_tree_rectangle<FT>&
|
const Kd_tree_rectangle<FT>&
|
||||||
bounding_box() const
|
bounding_box() const
|
||||||
{
|
{
|
||||||
if(! is_built()){
|
if(! is_built()){
|
||||||
const_build();
|
const_build();
|
||||||
}
|
}
|
||||||
return *bbox;
|
return *bbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator
|
const_iterator
|
||||||
|
|
@ -351,23 +350,23 @@ public:
|
||||||
return pts.end();
|
return pts.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_type
|
size_type
|
||||||
size() const
|
size() const
|
||||||
{
|
{
|
||||||
return pts.size();
|
return pts.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print statistics of the tree.
|
// Print statistics of the tree.
|
||||||
std::ostream&
|
std::ostream&
|
||||||
statistics(std::ostream& s) const
|
statistics(std::ostream& s) const
|
||||||
{
|
{
|
||||||
if(! is_built()){
|
if(! is_built()){
|
||||||
const_build();
|
const_build();
|
||||||
}
|
}
|
||||||
s << "Tree statistics:" << std::endl;
|
s << "Tree statistics:" << std::endl;
|
||||||
s << "Number of items stored: "
|
s << "Number of items stored: "
|
||||||
<< root()->num_items() << std::endl;
|
<< root()->num_items() << std::endl;
|
||||||
s << "Number of nodes: "
|
s << "Number of nodes: "
|
||||||
<< root()->num_nodes() << std::endl;
|
<< root()->num_nodes() << std::endl;
|
||||||
s << " Tree depth: " << root()->depth() << std::endl;
|
s << " Tree depth: " << root()->depth() << std::endl;
|
||||||
return s;
|
return s;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue