Change the Power_test

This commit is contained in:
Andreas Fabri 2016-03-24 17:52:44 +01:00 committed by Jane Tournois
parent f7302597aa
commit 9e94ee6178
14 changed files with 60 additions and 102 deletions

View File

@ -3971,7 +3971,7 @@ namespace CartesianKernelFunctors {
};
template < typename K >
class Power_test_3
class Power_side_of_power_sphere_3
{
public:
typedef typename K::Weighted_point_3 Weighted_point_3;

View File

@ -75,7 +75,7 @@
#include <CGAL/internal/Static_filters/Side_of_oriented_sphere_3.h>
#include <CGAL/internal/Static_filters/Compare_squared_radius_3.h>
#include <CGAL/internal/Static_filters/Compare_weighted_squared_radius_3.h>
#include <CGAL/internal/Static_filters/Power_test_3.h>
#include <CGAL/internal/Static_filters/Power_side_of_power_sphere_3.h>
// #include <CGAL/internal/Static_filters/Coplanar_orientation_3.h>
@ -85,7 +85,6 @@
// - add more predicates :
// - all lexicographical comparisons
// - left_turn (via generic adapter to orientation)
// - power_tests
// - others ?
// - benchmark on more algorithms.
// - improve fit_in_double() for other NTs (MP_Float, Lazy). cf tools.h.
@ -144,7 +143,7 @@ public:
typedef Static_filters_predicates::Compare_squared_radius_3<K_base> Compare_squared_radius_3;
typedef Static_filters_predicates::Compare_weighted_squared_radius_3<K_base> Compare_weighted_squared_radius_3;
typedef Static_filters_predicates::Power_test_3<K_base> Power_test_3;
typedef Static_filters_predicates::Power_side_of_power_sphere_3<K_base> Power_side_of_power_sphere_3;
Orientation_2
orientation_2_object() const
@ -204,8 +203,8 @@ Compare_y_2
compare_squared_radius_3_object() const
{ return Compare_squared_radius_3(); }
Power_test_3 power_test_3_object() const
{ return Power_test_3();}
Power_side_of_power_sphere_3 power_side_of_power_sphere_3_object() const
{ return Power_side_of_power_sphere_3();}
Compare_weighted_squared_radius_3
compare_weighted_squared_radius_3_object() const

View File

@ -4286,7 +4286,7 @@ namespace HomogeneousKernelFunctors {
}
};
template < typename K >
class Power_test_3
class Power_side_of_power_sphere_3
{
public:
typedef typename K::RT RT;

View File

@ -394,7 +394,7 @@ public:
{
K traits;
typename K::Orientation_3 orientation = traits.orientation_3_object();
typename K::Power_test_3 power_test = traits.power_test_3_object();
typename K::Power_side_of_power_sphere_3 power_test = traits.power_side_of_power_sphere_3_object();
typename K::Orientation o = orientation(p,q,r,s);
typename K::Oriented_side os = power_test(p,q,r,s,t);
CGAL_assertion( o != COPLANAR);

View File

@ -559,8 +559,8 @@ CGAL_Kernel_pred_RT(Orientation_2,
orientation_2_object)
CGAL_Kernel_pred_RT(Orientation_3,
orientation_3_object)
CGAL_Kernel_pred_RT(Power_test_3,
power_test_3_object)
CGAL_Kernel_pred_RT(Power_side_of_power_sphere_3,
power_side_of_power_sphere_3_object)
CGAL_Kernel_pred_RT(Compare_power_distance_3,
compare_power_distance_3_object)
CGAL_Kernel_pred_RT(Compare_weighted_squared_radius_3,

View File

@ -170,9 +170,9 @@ public:
{
CGAL_precondition(Rt().orientation_3_object()(p,q,r,s) == CGAL::POSITIVE);
// We use Power_test_3: it is static filtered and
// We use power_side_of_power_sphere_3: it is static filtered and
// we know that p,q,r,s are positive oriented
typename Rt::Power_test_3 power_test = Rt().power_test_3_object();
typename Rt::power_side_of_power_sphere_3 power_side_of_power_sphere = Rt().power_side_of_power_sphere_3_object();
// Compute denominator to swith to exact if it is 0
FT num_x, num_y, num_z, den;

View File

@ -60,7 +60,7 @@ The type for points.
A predicate type for power test. Belongs to the
`RegularTriangulationTraits_3` concept.
*/
typedef unspecified_type Power_test_3;
typedef unspecified_type Power_side_of_power_sphere_3;
/*!
A predicate type to compare power distance. Belongs to the
@ -175,7 +175,7 @@ for a given last point should be needed.
`FT operator() ( Weighted_point_3 p, Weighted_point_3 q, Weighted_point_3 r, Weighted_point_3 s, Weighted_point_3 t);`
*/
typedef unspecified_type Compute_critical_squared_radius_3;
typedef unspecified_type Compute_power_distance_to_power_sphere_3;
/// @}
@ -185,7 +185,7 @@ typedef unspecified_type Compute_critical_squared_radius_3;
/*!
*/
Power_test_3 power_test_3_object();
Power_side_of_power_sphere_3 power_side_of_power_sphere_3_object();
/*!
@ -233,8 +233,8 @@ compute_squared_radius_smallest_orthogonal_sphere_3_object() ;
/*!
*/
Compute_critical_squared_radius_3
compute_critical_squared_radius_3_object();
Compute_power_distance_to_power_sphere_3
compute_power_distance_to_power_sphere_3_object();
/// @}

View File

@ -87,7 +87,7 @@ Let \f$ {z(p,q,r,s)}^{(w)}\f$ be the power sphere of the weighted points
\pre `p, q, r, s` are not coplanar.
Note that with this definition, if all the points have a weight equal
to 0, then
`power_test_3(p,q,r,s,t)` = `side_of_oriented_sphere(p,q,r,s,t)`.
`power_side_of_power_sphere_3(p,q,r,s,t)` = `side_of_oriented_sphere(p,q,r,s,t)`.
<HR WIDTH=50%>
@ -98,7 +98,7 @@ definition analogous to the previous method, for coplanar points,
with the power circle \f$ {z(p,q,r)}^{(w)}\f$.
\pre `p, q, r` are not collinear and `p, q, r, t` are coplanar.
If all the points have a weight equal to 0, then
`power_test_3(p,q,r,t)` = `side_of_oriented_circle(p,q,r,t)`.
`power_side_of_power_sphere_3(p,q,r,t)` = `side_of_oriented_circle(p,q,r,t)`.
<HR WIDTH=50%>
@ -108,7 +108,7 @@ which is the same for collinear points, where \f$ {z(p,q)}^{(w)}\f$ is the
power segment of `p` and `q`.
\pre `p` and `q` have different bare points, and `p, q, t` are collinear.
If all points have a weight equal to 0, then
`power_test_3(p,q,t)` gives the same answer as the kernel predicate
`power_side_of_power_sphere_3(p,q,t)` gives the same answer as the kernel predicate
`s(p,q).has_on(t)` would give, where `s(p,q)` denotes the
segment with endpoints `p` and `q`.
@ -122,7 +122,7 @@ have equal coordinates, then it returns the comparison of the weights
\pre `p` and `q` have equal bare points.
*/
typedef unspecified_type Power_test_3;
typedef unspecified_type Power_side_of_power_sphere_3;
/*!
@ -209,7 +209,7 @@ typedef unspecified_type Construct_ray_3;
/*!
*/
Power_test_3 power_test_3_object();
Power_side_of_power_sphere_3 power_side_of_power_sphere_3_object();
/*!

View File

@ -943,7 +943,7 @@ namespace CGAL {
power_test(const Weighted_point &p, const Weighted_point &q) const
{
CGAL_triangulation_precondition(this->equal(p, q));
return geom_traits().power_test_3_object()(p, q);
return geom_traits().power_side_of_power_sphere_3_object()(p, q);
}
Oriented_side
@ -951,7 +951,7 @@ namespace CGAL {
const Weighted_point &r) const
{
CGAL_triangulation_precondition(this->collinear(p, q, r));
return geom_traits().power_test_3_object()(p, q, r);
return geom_traits().power_side_of_power_sphere_3_object()(p, q, r);
}
Oriented_side
@ -959,7 +959,7 @@ namespace CGAL {
const Weighted_point &r, const Weighted_point &s) const
{
CGAL_triangulation_precondition(this->coplanar(p, q, r, s));
return geom_traits().power_test_3_object()(p, q, r, s);
return geom_traits().power_side_of_power_sphere_3_object()(p, q, r, s);
}
Oriented_side
@ -967,7 +967,7 @@ namespace CGAL {
const Weighted_point &r, const Weighted_point &s,
const Weighted_point &t) const
{
return geom_traits().power_test_3_object()(p, q, r, s, t);
return geom_traits().power_side_of_power_sphere_3_object()(p, q, r, s, t);
}
bool in_conflict_3(const Weighted_point &p, const Cell_handle c) const

View File

@ -47,7 +47,7 @@ public:
// Before this type was Point
typedef Point_3 Point;
typedef typename K::Power_test_3 Power_test_3;
typedef typename K::Power_side_of_power_sphere_3 Power_side_of_power_sphere_3;
typedef typename K::Compare_power_distance_3 Compare_power_distance_3;
typedef typename K::Construct_weighted_circumcenter_3 Construct_weighted_circumcenter_3;
@ -65,8 +65,8 @@ public:
Compare_weighted_squared_radius_3;
Power_test_3 power_test_3_object() const
{ return K().power_test_3_object(); }
Power_side_of_power_sphere_3 power_side_of_power_sphere_3_object() const
{ return K().power_side_of_power_sphere_3_object(); }
Compare_power_distance_3 compare_power_distance_3_object() const
{ return K().compare_power_distance_3_object(); }

View File

@ -26,15 +26,14 @@ _test_cls_regular_euclidean_traits_3 (const Traits &)
typedef typename Traits::Bare_point Bare_point;
typedef typename Traits::Segment_3 Segment_3;
typedef typename Traits::Power_test_3 Power_test_3;
typedef typename Traits::Power_side_of_power_sphere_3
Power_side_of_power_sphere_3;
typedef typename Traits::Compare_power_distance_3
Compare_power_distance_3;
typedef typename Traits::In_smallest_orthogonal_sphere_3
In_smallest_orthogonal_sphere_3;
typedef typename Traits::Side_of_bounded_orthogonal_sphere_3
Side_of_bounded_orthogonal_sphere_3;
typedef typename Traits::Does_simplex_intersect_dual_support_3
Does_simplex_intersect_dual_support_3;
typedef typename Traits::Construct_weighted_circumcenter_3
Construct_weighted_circumcenter_3;
typedef typename Traits::Compute_power_product_3
@ -44,19 +43,18 @@ _test_cls_regular_euclidean_traits_3 (const Traits &)
Compute_squared_radius_smallest_orthogonal_sphere_3;
typedef typename Traits::
Compute_critical_squared_radius_3
Compute_critical_squared_radius_3;
Compute_power_distance_to_power_sphere_3
Compute_power_distance_to_power_sphere_3;
Traits traits;
Power_test_3 power_test = traits.power_test_3_object();
Power_side_of_power_sphere_3 power_test =
traits.power_side_of_power_sphere_3_object();
Compare_power_distance_3 compare_power_distance =
traits.compare_power_distance_3_object();
In_smallest_orthogonal_sphere_3 in_smallest_orthogonal_sphere =
traits.in_smallest_orthogonal_sphere_3_object();
Side_of_bounded_orthogonal_sphere_3 side_of_bounded_orthogonal_sphere =
traits.side_of_bounded_orthogonal_sphere_3_object();
Does_simplex_intersect_dual_support_3 does_simplex_intersect_dual_support =
traits.does_simplex_intersect_dual_support_3_object();
Construct_weighted_circumcenter_3 weighted_circumcenter =
traits.construct_weighted_circumcenter_3_object();
Compute_power_product_3 power_product =
@ -64,8 +62,8 @@ _test_cls_regular_euclidean_traits_3 (const Traits &)
Compute_squared_radius_smallest_orthogonal_sphere_3
squared_radius_smallest_orthogonal_sphere =
traits.compute_squared_radius_smallest_orthogonal_sphere_3_object();
Compute_critical_squared_radius_3 critical_squared_radius =
traits.compute_critical_squared_radius_3_object();
Compute_power_distance_to_power_sphere_3 compute_power_distance_to_power_sphere_3 =
traits.compute_power_distance_to_power_sphere_3_object();
// test of Does_simplex_intersect_dual_support_3
@ -84,45 +82,6 @@ _test_cls_regular_euclidean_traits_3 (const Traits &)
Weighted_point wp04(p0,18.);
Weighted_point wp05(p0,24.);
assert(does_simplex_intersect_dual_support(wp0,wp1,wp2,wp3)
== CGAL::ON_UNBOUNDED_SIDE);
assert(does_simplex_intersect_dual_support(wp1,wp0,wp2,wp3)
== CGAL::ON_UNBOUNDED_SIDE);
assert(does_simplex_intersect_dual_support(wp01,wp1,wp2,wp3)
== CGAL::ON_BOUNDARY);
assert(does_simplex_intersect_dual_support(wp01,wp2,wp1,wp3)
== CGAL::ON_BOUNDARY);
assert(does_simplex_intersect_dual_support(wp02,wp1,wp2,wp3)
== CGAL::ON_BOUNDED_SIDE);
assert(does_simplex_intersect_dual_support(wp2,wp1,wp02,wp3)
== CGAL::ON_BOUNDED_SIDE);
assert(does_simplex_intersect_dual_support(wp0,wp1,wp2)
== CGAL::ON_BOUNDARY);
assert(does_simplex_intersect_dual_support(wp1,wp0,wp2)
== CGAL::ON_BOUNDARY);
assert(does_simplex_intersect_dual_support(wp01,wp1,wp2)
== CGAL::ON_BOUNDED_SIDE);
assert(does_simplex_intersect_dual_support(wp01,wp2,wp1)
== CGAL::ON_BOUNDED_SIDE);
assert(does_simplex_intersect_dual_support(wp03,wp1,wp2)
== CGAL::ON_UNBOUNDED_SIDE);
assert(does_simplex_intersect_dual_support(wp2,wp1,wp03)
== CGAL::ON_UNBOUNDED_SIDE);
assert(does_simplex_intersect_dual_support(wp0,wp1)
== CGAL::ON_BOUNDED_SIDE);
assert(does_simplex_intersect_dual_support(wp1,wp0)
== CGAL::ON_BOUNDED_SIDE);
assert(does_simplex_intersect_dual_support(wp04,wp1)
== CGAL::ON_BOUNDARY);
assert(does_simplex_intersect_dual_support(wp1,wp04)
== CGAL::ON_BOUNDARY);
assert(does_simplex_intersect_dual_support(wp05,wp1)
== CGAL::ON_UNBOUNDED_SIDE);
assert(does_simplex_intersect_dual_support(wp1,wp05)
== CGAL::ON_UNBOUNDED_SIDE);
// test of Construct_weighted_circumcenter_3 and compare_power_distance
std::cout << "test of Construct_weighted_circumcenter_3" << std::endl;
@ -233,19 +192,19 @@ _test_cls_regular_euclidean_traits_3 (const Traits &)
Weighted_point wt(Bare_point(1.,1.,1.), 0.);
// this test requires a weighted point with a zero weight
assert( power_product(wc,wt) ==
critical_squared_radius(wq11,wq21,wq31,wq41,wt));
compute_power_distance_to_power_sphere_3(wq11,wq21,wq31,wq41,wt));
wc = Weighted_point(
weighted_circumcenter(wp0,wp1,wp2,wp3),
squared_radius_smallest_orthogonal_sphere(wp0,wp1,wp2,wp3));
assert( power_product(wc,wt) ==
critical_squared_radius(wp0,wp1,wp2,wp3,wt));
compute_power_distance_to_power_sphere_3(wp0,wp1,wp2,wp3,wt));
wc = Weighted_point(
weighted_circumcenter(wp01,wp1,wp2,wp3),
squared_radius_smallest_orthogonal_sphere(wp01,wp1,wp2,wp3));
assert( power_product(wc,wt) ==
critical_squared_radius(wp01,wp1,wp2,wp3,wt));
compute_power_distance_to_power_sphere_3(wp01,wp1,wp2,wp3,wt));
// test power_test
// null weights

View File

@ -42,9 +42,9 @@ int degeneracy_counter = 0;
// This gives a rough idea of how degenerate a data set is.
struct traits : public bare_traits
{
struct Power_test_3 : public bare_traits::Power_test_3
struct Power_side_of_power_sphere_3 : public bare_traits::Power_side_of_power_sphere_3
{
typedef bare_traits::Power_test_3 P3;
typedef bare_traits::Power_side_of_power_sphere_3 P3;
Oriented_side operator() (const Weighted_point &p0,
const Weighted_point &p) const
{
@ -81,8 +81,8 @@ struct traits : public bare_traits
}
};
Power_test_3 power_test_3_object() const
{ return Power_test_3(); }
Power_side_of_power_sphere_3 power_side_of_power_sphere_3_object() const
{ return Power_side_of_power_sphere_3(); }
};

View File

@ -49,7 +49,7 @@ public:
public:
CGAL_Kernel_pred(Compare_weighted_squared_radius_3,compare_weighted_squared_radius_3_object)
CGAL_Kernel_pred(Power_test_3,power_test_3_object)
CGAL_Kernel_pred(Power_side_of_power_sphere_3,power_side_of_power_sphere_3_object)
};
@ -149,7 +149,7 @@ Weighted_point_3 convert_to_pair(const Exact_traits::Weighted_point_3& wp)
return Weighted_point_3(wp_with_sf, wp_without_sf);
}
void test_power_test_3(){
void test_power_side_of_power_sphere_3(){
CGAL::Cartesian_converter<FK_without_SF,Exact_kernel> convert_to_exact;
Weighted_point_3 p=my_rand_wp3();
@ -159,10 +159,10 @@ void test_power_test_3(){
Weighted_point_3 query_pt=my_rand_wp3();
//test with random points
K3().power_test_3_object()(p,q,r,s,query_pt);
K3().power_test_3_object()(p,q,r,query_pt);
K3().power_test_3_object()(p,q,query_pt);
K3().power_test_3_object()(p,query_pt);
K3().power_side_of_power_sphere_3_object()(p,q,r,s,query_pt);
K3().power_side_of_power_sphere_3_object()(p,q,r,query_pt);
K3().power_side_of_power_sphere_3_object()(p,q,query_pt);
K3().power_side_of_power_sphere_3_object()(p,query_pt);
//test in degenerate case
Exact_traits::Weighted_point_3::Point origin(0,0,0);
@ -176,32 +176,32 @@ void test_power_test_3(){
CGAL::squared_distance(origin,Exact_traits().construct_weighted_circumcenter_3_object()(p_e,q_e,r_e,s_e))-
Exact_traits().compute_squared_radius_smallest_orthogonal_sphere_3_object()(p_e,q_e,r_e,s_e)
);
assert(Exact_traits().power_test_3_object()(p_e,q_e,r_e,s_e,tmp)==CGAL::ON_ORIENTED_BOUNDARY);
assert(Exact_traits().power_side_of_power_sphere_3_object()(p_e,q_e,r_e,s_e,tmp)==CGAL::ON_ORIENTED_BOUNDARY);
Weighted_point_3 ortho_pqrs = convert_to_pair(tmp);
tmp=Exact_traits::Weighted_point_3(
Exact_traits().construct_weighted_circumcenter_3_object()(p_e,q_e,r_e),
-Exact_traits().compute_squared_radius_smallest_orthogonal_sphere_3_object()(p_e,q_e,r_e)
);
assert(Exact_traits().power_test_3_object()(p_e,q_e,r_e,tmp)==CGAL::ON_ORIENTED_BOUNDARY);
assert(Exact_traits().power_side_of_power_sphere_3_object()(p_e,q_e,r_e,tmp)==CGAL::ON_ORIENTED_BOUNDARY);
Weighted_point_3 ortho_pqr = convert_to_pair(tmp);
tmp=Exact_traits::Weighted_point_3(
Exact_traits().construct_weighted_circumcenter_3_object()(p_e,q_e),
-Exact_traits().compute_squared_radius_smallest_orthogonal_sphere_3_object()(p_e,q_e)
);
assert(Exact_traits().power_test_3_object()(p_e,q_e,tmp)==CGAL::ON_ORIENTED_BOUNDARY);
assert(Exact_traits().power_side_of_power_sphere_3_object()(p_e,q_e,tmp)==CGAL::ON_ORIENTED_BOUNDARY);
Weighted_point_3 ortho_pq = convert_to_pair(tmp);
K3().power_test_3_object()(p,q,r,s,ortho_pqrs);
K3().power_test_3_object()(p,q,r ,ortho_pqr);
K3().power_test_3_object()(p,q ,ortho_pq);
K3().power_side_of_power_sphere_3_object()(p,q,r,s,ortho_pqrs);
K3().power_side_of_power_sphere_3_object()(p,q,r ,ortho_pqr);
K3().power_side_of_power_sphere_3_object()(p,q ,ortho_pq);
// Then with some perturbation on coordinates and weight.
perturb(p, 1.0/(1<<25)/(1<<20)); // 2^-45
K3().power_test_3_object()(p,q,r,s,ortho_pqrs);
K3().power_test_3_object()(p,q,r ,ortho_pqr);
K3().power_test_3_object()(p,q ,ortho_pq);
K3().power_side_of_power_sphere_3_object()(p,q,r,s,ortho_pqrs);
K3().power_side_of_power_sphere_3_object()(p,q,r ,ortho_pqr);
K3().power_side_of_power_sphere_3_object()(p,q ,ortho_pq);
}
@ -238,9 +238,9 @@ int main(int argc, char **argv)
for(int i=0; i<loops; ++i)
test_compare_weighted_squared_radius_3();
std::cout << "Testing Power_test_3" << std::endl;
std::cout << "Testing power_side_of_power_sphere_3" << std::endl;
for(int i=0; i<loops; ++i)
test_power_test_3();
test_power_side_of_power_sphere_3();
return 0;
}