Added tparam to doc

This commit is contained in:
m.overtheil 2014-12-04 15:58:03 +01:00
parent d9a132b72e
commit 1e6b69ccd9
19 changed files with 216 additions and 54 deletions

View File

@ -9,7 +9,7 @@ To optimize distance computations squared distances are used.
\cgalHeading{Parameters}
Expects for the first template argument a model of the concept
\tparam Traits must be a model of the concept
`SearchTraits`, for example `Search_traits_2<Simple_cartesian<double> >`.
\cgalModels `OrthogonalDistance`

View File

@ -11,7 +11,7 @@ Euclidean distance between a \f$ d\f$-dimensional sphere and a
\cgalHeading{Parameters}
Expects for the template argument a model of the concept `SearchTraits`,
\tparam Traits must be a model of the concept `SearchTraits`,
for example `Simple_cartesian_d<double>`.
\cgalModels `GeneralDistance`

View File

@ -10,7 +10,7 @@ by a `d`-dim square with side length \f$ \epsilon\f$.
\cgalHeading{Parameters}
Expects for the template argument a model of the concept
\tparam Traits must be a model of the concept
`SearchTraits`, for example `CGAL::Search_traits_2<CGAL::Simple_cartesian<double> >`.
\cgalModels `FuzzyQueryItem`

View File

@ -10,7 +10,7 @@ as inner approximation a sphere with radius \f$ r-\epsilon\f$.
\cgalHeading{Parameters}
Expects for the template argument a model of the concept
\tparam Traits must be a model of the concept
`SearchTraits`, for example `CGAL::Cartesian_d<double>`.
\cgalModels `FuzzyQueryItem`

View File

@ -8,19 +8,19 @@ on a tree. The tree may have extended or unextended nodes.
\cgalHeading{Parameters}
Expects for the first template argument a model of the concept `SearchTraits`,
\tparam Traits must be a model of the concept `SearchTraits`,
for example `Search_traits_2<Simple_cartesian<double> >`.
Expects for the second template argument a model of the
\tparam GeneralDistance must be a model of the
concept `GeneralDistance`. If `Traits` is
`Search_traits_adapter<Key,PointPropertyMap,BaseTraits>`
the default type is `Distance_adapter<Key,PointPropertyMap,Euclidean_distance<BaseTraits> >`,
and `Euclidean_distance<Traits>` otherwise.
Expects for third template argument a model of the concept `Splitter`.
\tparam Splitter must be a model of the concept `Splitter`.
The default type is `Sliding_midpoint<Traits>`.
Expects for fourth template argument a model of the concept `SpatialTree`.
\tparam SpatialTree must be a model of the concept `SpatialTree`.
The default type is `Kd_tree<Traits,Splitter,Tag_false>`. The
template argument `Tag_false` makes that the tree is built with unextended nodes.

View File

@ -9,16 +9,16 @@ extended or unextended nodes.
\cgalHeading{Parameters}
Expects for the first template argument an implementation of the concept `SearchTraits`,
\tparam Traits must be an implementation of the concept `SearchTraits`,
for example `Simple_cartesian<double>`.
Expects for the second template argument a model of the
\tparam Splitter must be a model of the
concept `GeneralDistance`. If `Traits` is
`Search_traits_adapter<Key,PointPropertyMap,BaseTraits>`
the default type is `Distance_adapter<Key,PointPropertyMap,Euclidean_distance<BaseTraits> >`,
and `Euclidean_distance<Traits>` otherwise.
Expects for fourth template argument an implementation of the concept `SpatialTree`.
\tparam SpatialTree must be an implementation of the concept `SpatialTree`.
The default type is `Kd_tree<Traits, Splitter, Tag_false>`. The
template argument `Tag_false` makes that the tree is built with unextended nodes.

View File

@ -15,9 +15,11 @@ along the node's cutting dimension.
\cgalHeading{Parameters}
Expects for the template argument a model of the concept `SearchTraits`,
\tparam Traits must be a model of the concept `SearchTraits`,
for example `Search_traits_2<Simple_cartesian<double> >`, or `Cartesian_d<double>`.
\tparam Splitter must be a model of the concept `Splitter`.
*/
template< typename Traits, typename Splitter, typename UseExtendedNode >
class Kd_tree_node {

View File

@ -12,7 +12,7 @@ and a `d`-dimensional iso-box defined as a `k-d` tree rectangle.
\cgalHeading{Parameters}
Expects for the template argument a model for the concept
\tparam Traits must be a model for the concept
`SearchTraits`, for example `Search_traits_3<Simple_cartesian<double> >`.
\cgalModels `GeneralDistance`

View File

@ -7,19 +7,19 @@ The class `Orthogonal_incremental_neighbor_search` implements incremental neares
\cgalHeading{Parameters}
Expects for the first template argument a model of the concept `SearchTraits`,
\tparam Traits must be a model of the concept `SearchTraits`,
for example `Search_traits_2<Simple_cartesian<double> >`.
Expects for the second template argument a model of the
concept `GeneralDistance`. If `Traits` is
\tparam OrthogonalDistance must be a model of the
concept `OrthogonalDistance`. If `Traits` is
`Search_traits_adapter<Key,PointPropertyMap,BaseTraits>`
the default type is `Distance_adapter<Key,PointPropertyMap,Euclidean_distance<BaseTraits> >`,
and `Euclidean_distance<Traits>` otherwise.
Expects for third template argument a model of the concept `Splitter`.
\tparam Splitter must be a model of the concept `Splitter`.
The default type is `Sliding_midpoint<Traits>`.
Expects for fourth template argument a model of the concept `SpatialTree`.
\tparam SpatialTree must be a model of the concept `SpatialTree`.
The default type is `Kd_tree<Traits, Splitter, Tag_true>`. The
template argument must be `Tag_true` because orthogonal search needs extended
kd tree nodes.

View File

@ -10,7 +10,7 @@ Added Dimension
\cgalModifEnd
\cgalHeading{Parameters}
Expects for the template argument a model of the concept `Kernel`,
\tparam Kernel must be a model of the concept `Kernel`,
for example `Simple_cartesian<double>` or `Simple_cartesian<Gmpq>`.
\cgalModels `SearchTraits`

View File

@ -10,7 +10,7 @@ Added Dimension
\cgalModifEnd
\cgalHeading{Parameters}
Expects for the template argument a model of the concept `Kernel`,
\tparam Kernel must be a model of the concept `Kernel`,
for example `Simple_cartesian<double>` or `Simple_cartesian<Gmpq>`.
\cgalModels `SearchTraits`

View File

@ -10,12 +10,12 @@ in a nearest neighbor search algorithm, this class must be used as distance.
\cgalHeading{Parameters}
`Key` is a type that is associated to a point of type `Base_distance::Point_d`.
\tparam Key is a type that is associated to a point of type `Base_distance::Point_d`.
`PointPropertyMap` is a model of `LvaluePropertyMap`
\tparam PointPropertyMap is a model of `LvaluePropertyMap`
with `Key` as `key_type` and `Base_distance::Point_d` as `value_type`.
`Base_distance` is a model of either `GeneralDistance` or `OrthogonalDistance`.
\tparam Base_distance is a model of either `GeneralDistance` or `OrthogonalDistance`.
\cgalModels `GeneralDistance` if Base_distance is a model of `GeneralDistance`
\cgalModels `OrthogonalDistance` if Base_distance is a model of `OrthogonalDistance`

View File

@ -12,8 +12,10 @@ Added Dimension
\cgalHeading{Parameters}
Expects for the first template argument a model of the concept `Kernel_d`
(for example `Cartesian_d<double>`) and for the second argument a `Dimension_tag`
\tparam Kernel must be a model of the concept `Kernel_d`
(for example `Cartesian_d<double>`)
\tparam Dim must be a `Dimension_tag`
(default value is `Dynamic_dimension_tag`).
\cgalModels `SearchTraits`

View File

@ -16,12 +16,12 @@ the ratio of the resulting rectangles.
\cgalHeading{Parameters}
Expects for the first template argument a model of
\tparam Traits must be a model of
the concept `SearchTraits`,
for example `Simple_cartesian<double>`.
Expects for the second template argument a model of the concept `SpatialSeparator`.
It has as default value the type, `Plane_separator<Traits::FT>`.
\tparam SpatialSeparator must be a model of the concept `SpatialSeparator`.
It has as default value the type `Plane_separator<Traits::FT>`.
\cgalModels `Splitter`

View File

@ -12,7 +12,7 @@ the transformed distance \f$ {\sigma_{i=1}^{i=d} \, w_i(r_i-q_i)^p}\f$ instead o
\cgalHeading{Parameters}
Expects for the template argument a model of the concept
\tparam Traits must be a model of the concept
`SearchTraits`, for example `Search_traits_2<Kernel>`.
\cgalModels `OrthogonalDistance`

View File

@ -24,6 +24,39 @@ struct Distance {
return distance;
}
template <class TreeTraits>
double min_distance_to_rectangle(const Point& p,
const CGAL::Kd_tree_rectangle<TreeTraits>& b,std::vector<double>& dists){
double distance(0.0), h = p.x();
if (h < b.min_coord(0)){
dists[0] = (b.min_coord(0)-h);
distance += dists[0]*dists[0];
}
if (h > b.max_coord(0)){
dists[0] = (h-b.max_coord(0));
distance += dists[0]*dists[0];
}
h=p.y();
if (h < b.min_coord(1)){
dists[1] = (b.min_coord(1)-h);
distance += dists[1]*dists[1];
}
if (h > b.max_coord(1)){
dists[1] = (h-b.max_coord(1));
distance += dists[1]*dists[1];
}
h=p.z();
if (h < b.min_coord(2)){
dists[2] = (b.min_coord(2)-h);
distance += dists[2]*dists[2];
}
if (h > b.max_coord(2)){
dists[2] = (h-b.max_coord(2));
distance += dists[2]*dists[2];
}
return distance;
}
template <class TreeTraits>
double max_distance_to_rectangle(const Point& p,
const CGAL::Kd_tree_rectangle<TreeTraits>& b) const {
@ -41,6 +74,23 @@ struct Distance {
return d0 + d1 + d2;
}
template <class TreeTraits>
double max_distance_to_rectangle(const Point& p,
const CGAL::Kd_tree_rectangle<TreeTraits>& b,std::vector<double>& dists){
double h = p.x();
dists[0] = (h >= (b.min_coord(0)+b.max_coord(0))/2.0) ?
(h-b.min_coord(0)) : (b.max_coord(0)-h);
h=p.y();
dists[1] = (h >= (b.min_coord(1)+b.max_coord(1))/2.0) ?
(h-b.min_coord(1)) : (b.max_coord(1)-h);
h=p.z();
dists[2] = (h >= (b.min_coord(2)+b.max_coord(2))/2.0) ?
(h-b.min_coord(2)) : (b.max_coord(2)-h);
return dists[0] * dists[0] + dists[1] * dists[1] + dists[2] * dists[2];
}
double new_distance(double& dist, double old_off, double new_off,
int /* cutting_dimension */) const {
return dist + new_off*new_off - old_off*old_off;

View File

@ -1,6 +1,8 @@
struct Point {
double vec[3];
Point(){}
Point() { vec[0]= vec[1] = vec[2] = 0; }
Point (double x, double y, double z) { vec[0]=x; vec[1]=y; vec[2]=z; }

View File

@ -71,41 +71,65 @@ namespace CGAL {
typedef typename SearchTraits::Point_d Point_d;
typedef Point_d Query_item;
typedef typename internal::Euclidean_distance_base<SearchTraits>::Dimension D;
typedef typename internal::Euclidean_distance_base<SearchTraits>::Dimension D;
// default constructor
Euclidean_distance(const SearchTraits& traits_=SearchTraits()):traits(traits_) {}
// default constructor
Euclidean_distance(const SearchTraits& traits_=SearchTraits()):traits(traits_) {}
inline FT transformed_distance(const Query_item& q, const Point_d& p) const {
return transformed_distance(q,p, D());
}
//Dynamic version for runtime dimension
inline FT transformed_distance(const Query_item& q, const Point_d& p, Dynamic_dimension_tag dt) const {
FT distance = FT(0);
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it=traits.construct_cartesian_const_iterator_d_object();
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));
}
return distance;
FT distance = FT(0);
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it=traits.construct_cartesian_const_iterator_d_object();
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));
}
return distance;
}
//Generic version for DIM > 3
template < int DIM >
inline FT transformed_distance(const Query_item& q, const Point_d& p, Dimension_tag<DIM> dt) const {
std::cerr << "here goes the generic code" <<std::endl;
return 0;
}
FT distance = FT(0);
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it=traits.construct_cartesian_const_iterator_d_object();
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));
}
return distance;
}
// template <>
//DIM = 2 loop unrolled
inline FT transformed_distance(const Query_item& q, const Point_d& p, Dimension_tag<2> dt) const {
std::cerr << "here goes the unrolled code for 3D" <<std::endl;
return 0;
}
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it=traits.construct_cartesian_const_iterator_d_object();
typename SearchTraits::Cartesian_const_iterator_d qit = construct_it(q),pit = construct_it(p);
FT distance = square(*qit - *pit);
qit++;pit++;
distance += square(*qit - *pit);
return distance;
}
inline FT transformed_distance(const Query_item& q, const Point_d& p) const {
return transformed_distance(q,p, D());
}
//DIM = 3 loop unrolled
inline FT transformed_distance(const Query_item& q, const Point_d& p, Dimension_tag<3> dt) const {
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it=traits.construct_cartesian_const_iterator_d_object();
typename SearchTraits::Cartesian_const_iterator_d qit = construct_it(q),pit = construct_it(p);
FT distance = square(*qit - *pit);
qit++;pit++;
distance += square(*qit - *pit);
qit++;pit++;
distance += square(*qit - *pit);
return distance;
}
inline FT min_distance_to_rectangle(const Query_item& q,

View File

@ -119,9 +119,11 @@ namespace CGAL {
}
//Dynamic version for runtime dimension
inline
FT
transformed_distance(const Query_item& q, const Point_d& p) const
transformed_distance(const Query_item& q, const Point_d& p, Dynamic_dimension_tag dt) const
{
FT distance = FT(0);
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it=
@ -140,7 +142,87 @@ namespace CGAL {
the_weights[i] * std::pow(CGAL::abs((*qit)-(*pit)),power);
return distance;
}
//Generic version for DIM > 3
template <int DIM>
inline FT
transformed_distance(const Query_item& q, const Point_d& p, Dimension_tag<DIM> dt) const
{
FT distance = FT(0);
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it=
traits.construct_cartesian_const_iterator_d_object();
Coord_iterator qit = construct_it(q),
qe = construct_it(q,1),
pit = construct_it(p);
if (power == FT(0)) {
for (unsigned int i = 0; qit != qe; ++qit, ++i)
if (the_weights[i] * CGAL::abs((*qit) - (*pit)) > distance)
distance = the_weights[i] * CGAL::abs((*qit)-(*pit));
}
else
for (unsigned int i = 0; qit != qe; ++qit, ++i)
distance +=
the_weights[i] * std::pow(CGAL::abs((*qit)-(*pit)),power);
return distance;
}
//DIM = 2 loop unrolled
inline FT
transformed_distance(const Query_item& q, const Point_d& p, Dimension_tag<2> dt) const
{
FT distance = FT(0);
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it=
traits.construct_cartesian_const_iterator_d_object();
Coord_iterator qit = construct_it(q),
pit = construct_it(p);
if (power == FT(0)) {
if (the_weights[0] * CGAL::abs((*qit) - (*pit)) > distance)
distance = the_weights[0] * CGAL::abs((*qit)-(*pit));
qit++;pit++;
if (the_weights[1] * CGAL::abs((*qit) - (*pit)) > distance)
distance = the_weights[1] * CGAL::abs((*qit)-(*pit));
}
else{
distance +=
the_weights[0] * std::pow(CGAL::abs((*qit)-(*pit)),power);
qit++;pit++;
distance +=
the_weights[1] * std::pow(CGAL::abs((*qit)-(*pit)),power);
}
return distance;
}
//DIM = 3 loop unrolled
inline FT
transformed_distance(const Query_item& q, const Point_d& p, Dimension_tag<3> dt) const
{
FT distance = FT(0);
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it=
traits.construct_cartesian_const_iterator_d_object();
Coord_iterator qit = construct_it(q),
pit = construct_it(p);
if (power == FT(0)) {
if (the_weights[0] * CGAL::abs((*qit) - (*pit)) > distance)
distance = the_weights[0] * CGAL::abs((*qit)-(*pit));
qit++;pit++;
if (the_weights[1] * CGAL::abs((*qit) - (*pit)) > distance)
distance = the_weights[1] * CGAL::abs((*qit)-(*pit));
qit++;pit++;
if (the_weights[2] * CGAL::abs((*qit) - (*pit)) > distance)
distance = the_weights[2] * CGAL::abs((*qit)-(*pit));
}
else{
distance +=
the_weights[0] * std::pow(CGAL::abs((*qit)-(*pit)),power);
qit++;pit++;
distance +=
the_weights[1] * std::pow(CGAL::abs((*qit)-(*pit)),power);
qit++;pit++;
distance +=
the_weights[2] * std::pow(CGAL::abs((*qit)-(*pit)),power);
}
return distance;
}
inline
FT