mirror of https://github.com/CGAL/cgal
Add Power_distance and Translated_point + use std::abs in test
This commit is contained in:
commit
a099cc2ea2
|
|
@ -0,0 +1,53 @@
|
|||
// Copyright (c) 2014
|
||||
// INRIA Saclay-Ile de France (France)
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation; either version 3 of the License,
|
||||
// or (at your option) any later version.
|
||||
//
|
||||
// Licensees holding a valid commercial license may use this file in
|
||||
// accordance with the commercial license agreement provided with the software.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
// Author(s) : Marc Glisse
|
||||
|
||||
#ifndef CGAL_EPECK_D_H
|
||||
#define CGAL_EPECK_D_H
|
||||
#include <CGAL/NewKernel_d/Cartesian_base.h>
|
||||
#include <CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h>
|
||||
#include <CGAL/NewKernel_d/Kernel_d_interface.h>
|
||||
#include <CGAL/internal/Exact_type_selector.h>
|
||||
|
||||
|
||||
namespace CGAL {
|
||||
#define CGAL_BASE \
|
||||
Cartesian_base_d<internal::Exact_field_selector<double>::Type, Dim>
|
||||
template<class Dim>
|
||||
struct Epeck_d_help1
|
||||
: CGAL_BASE
|
||||
{
|
||||
CGAL_CONSTEXPR Epeck_d_help1(){}
|
||||
CGAL_CONSTEXPR Epeck_d_help1(int d):CGAL_BASE(d){}
|
||||
};
|
||||
#undef CGAL_BASE
|
||||
#define CGAL_BASE \
|
||||
Kernel_d_interface< \
|
||||
Cartesian_wrap< \
|
||||
Epeck_d_help1<Dim>, \
|
||||
Epeck_d<Dim> > >
|
||||
template<class Dim>
|
||||
struct Epeck_d
|
||||
: CGAL_BASE
|
||||
{
|
||||
CGAL_CONSTEXPR Epeck_d(){}
|
||||
CGAL_CONSTEXPR Epeck_d(int d):CGAL_BASE(d){}
|
||||
};
|
||||
#undef CGAL_BASE
|
||||
}
|
||||
#endif
|
||||
|
|
@ -30,7 +30,7 @@ namespace CGAL {
|
|||
|
||||
template < typename Base_, typename AK_, typename EK_ >
|
||||
struct Cartesian_filter_K : public Base_,
|
||||
private Store_kernel<AK_>, private Store_kernel2<EK_>
|
||||
private Store_kernel<AK_>, private Store_kernel2<EK_>
|
||||
{
|
||||
CGAL_CONSTEXPR Cartesian_filter_K(){}
|
||||
CGAL_CONSTEXPR Cartesian_filter_K(int d):Base_(d){}
|
||||
|
|
@ -61,11 +61,11 @@ struct Cartesian_filter_K : public Base_,
|
|||
template<class T> struct Type : Get_type<Kernel_base,T> {};
|
||||
|
||||
template<class T,class D=void,class=typename Get_functor_category<Cartesian_filter_K,T>::type> struct Functor :
|
||||
Inherit_functor<Kernel_base,T,D> {};
|
||||
Inherit_functor<Kernel_base,T,D> {};
|
||||
template<class T,class D> struct Functor<T,D,Predicate_tag> {
|
||||
typedef typename Get_functor<AK, T>::type AP;
|
||||
typedef typename Get_functor<EK, T>::type EP;
|
||||
typedef Filtered_predicate2<EP,AP,C2E,C2A> type;
|
||||
typedef typename Get_functor<AK, T>::type AP;
|
||||
typedef typename Get_functor<EK, T>::type EP;
|
||||
typedef Filtered_predicate2<EP,AP,C2E,C2A> type;
|
||||
};
|
||||
// TODO:
|
||||
// template<class T> struct Functor<T,No_filter_tag,Predicate_tag> :
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ template <class Base_> struct Kernel_d_interface : public Base_ {
|
|||
typedef typename Get_functor<Base, Side_of_oriented_sphere_tag>::type Side_of_oriented_sphere_d;
|
||||
typedef typename Get_functor<Base, Power_side_of_power_sphere_tag>::type Power_side_of_power_sphere_d;
|
||||
typedef typename Get_functor<Base, Power_center_tag>::type Power_center_d;
|
||||
typedef typename Get_functor<Base, Power_distance_tag>::type Power_distance_d;
|
||||
typedef typename Get_functor<Base, Contained_in_affine_hull_tag>::type Contained_in_affine_hull_d;
|
||||
typedef typename Get_functor<Base, Construct_flat_orientation_tag>::type Construct_flat_orientation_d;
|
||||
typedef typename Get_functor<Base, In_flat_orientation_tag>::type In_flat_orientation_d;
|
||||
|
|
@ -74,6 +75,7 @@ template <class Base_> struct Kernel_d_interface : public Base_ {
|
|||
typedef typename Get_functor<Base, In_flat_power_side_of_power_sphere_tag>::type In_flat_power_side_of_power_sphere_d;
|
||||
typedef typename Get_functor<Base, Point_to_vector_tag>::type Point_to_vector_d;
|
||||
typedef typename Get_functor<Base, Vector_to_point_tag>::type Vector_to_point_d;
|
||||
typedef typename Get_functor<Base, Translated_point_tag>::type Translated_point_d;
|
||||
typedef typename Get_functor<Base, Scaled_vector_tag>::type Scaled_vector_d;
|
||||
typedef typename Get_functor<Base, Difference_of_vectors_tag>::type Difference_of_vectors_d;
|
||||
typedef typename Get_functor<Base, Difference_of_points_tag>::type Difference_of_points_d;
|
||||
|
|
@ -190,6 +192,7 @@ template <class Base_> struct Kernel_d_interface : public Base_ {
|
|||
Side_of_oriented_sphere_d side_of_oriented_sphere_d_object()const{ return Side_of_oriented_sphere_d(*this); }
|
||||
Power_side_of_power_sphere_d power_side_of_power_sphere_d_object()const{ return Power_side_of_power_sphere_d(*this); }
|
||||
Power_center_d power_center_d_object()const{ return Power_center_d(*this); }
|
||||
Power_distance_d power_distance_d_object()const{ return Power_distance_d(*this); }
|
||||
Side_of_bounded_sphere_d side_of_bounded_sphere_d_object()const{ return Side_of_bounded_sphere_d(*this); }
|
||||
Contained_in_affine_hull_d contained_in_affine_hull_d_object()const{ return Contained_in_affine_hull_d(*this); }
|
||||
Contained_in_linear_hull_d contained_in_linear_hull_d_object()const{ return Contained_in_linear_hull_d(*this); }
|
||||
|
|
@ -200,6 +203,7 @@ template <class Base_> struct Kernel_d_interface : public Base_ {
|
|||
In_flat_power_side_of_power_sphere_d in_flat_power_side_of_power_sphere_d_object()const{ return In_flat_power_side_of_power_sphere_d(*this); }
|
||||
Point_to_vector_d point_to_vector_d_object()const{ return Point_to_vector_d(*this); }
|
||||
Vector_to_point_d vector_to_point_d_object()const{ return Vector_to_point_d(*this); }
|
||||
Translated_point_d translated_point_d_object()const{ return Translated_point_d(*this); }
|
||||
Scaled_vector_d scaled_vector_d_object()const{ return Scaled_vector_d(*this); }
|
||||
Difference_of_vectors_d difference_of_vectors_d_object()const{ return Difference_of_vectors_d(*this); }
|
||||
Difference_of_points_d difference_of_points_d_object()const{ return Difference_of_points_d(*this); }
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ int main()
|
|||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <CGAL/NewKernel_d/Types/Weighted_point.h>
|
||||
#include <cmath>
|
||||
|
||||
//typedef CGAL::Cartesian_base_d<double,CGAL::Dimension_tag<2> > K0;
|
||||
//typedef CGAL::Cartesian_base_d<CGAL::Interval_nt_advanced,CGAL::Dimension_tag<2> > KA;
|
||||
|
|
@ -138,7 +139,7 @@ void test2(){
|
|||
typedef typename K1::Compute_squared_radius_d SR;
|
||||
typedef typename K1::Translated_point_d TP;
|
||||
typedef typename K1::Power_center_d PC;
|
||||
typedef typename CGAL::Get_functor<K1, CGAL::Power_distance_tag>::type PoD;
|
||||
typedef typename K1::Power_distance_d PoD;
|
||||
typedef typename K1::Weighted_point_d WP;
|
||||
typedef typename K1::Construct_weighted_point_d CWP;
|
||||
typedef typename K1::Point_drop_weight_d PDW;
|
||||
|
|
@ -209,7 +210,7 @@ void test2(){
|
|||
CWP cwp Kinit(construct_weighted_point_d_object);
|
||||
PDW pdw Kinit(point_drop_weight_d_object);
|
||||
PW pw Kinit(point_weight_d_object);
|
||||
PoD pod (k);
|
||||
PoD pod Kinit(power_distance_d_object);
|
||||
|
||||
CGAL_USE(bc);
|
||||
CGAL_USE(pol);
|
||||
|
|
@ -217,11 +218,12 @@ void test2(){
|
|||
CGAL_USE(cd);
|
||||
CGAL_USE(cli);
|
||||
CGAL_USE(cr);
|
||||
using std::abs;
|
||||
P a=cp(3,4);
|
||||
assert(pd(a)==2);
|
||||
assert(pv(a)[1]==4);
|
||||
P b=vp(cv(5,6,7));
|
||||
assert(fabs(b[0]-5./7)<.0001);
|
||||
assert(abs(b[0]-5./7)<.0001);
|
||||
assert(lc(b,a,1));
|
||||
assert(!lc(a,b,0));
|
||||
int rr[]={3,5,2};
|
||||
|
|
@ -235,8 +237,8 @@ void test2(){
|
|||
assert(cl(a,c)==CGAL::SMALLER);
|
||||
assert(ll(b,c));
|
||||
assert(cl(c,b)==CGAL::LARGER);
|
||||
assert(fabs(m(a,c)[0]-3)<.0001);
|
||||
assert(fabs(m(a,c)[1]-4.5)<.0001);
|
||||
assert(abs(m(a,c)[0]-3)<.0001);
|
||||
assert(abs(m(a,c)[1]-4.5)<.0001);
|
||||
P d=cp(r,r+3,CGAL::Homogeneous_tag());
|
||||
S s=cs(c,d);
|
||||
std::cout << cc(a,1) << std::endl;
|
||||
|
|
@ -291,9 +293,9 @@ void test2(){
|
|||
assert(v.size()==1);
|
||||
assert(lr(tab3+0,tab3+2)==1);
|
||||
H h=ch(tab2+1,tab2+3,tab2[0]);
|
||||
assert(fabs(va(h,x2)-1)<.0001);
|
||||
assert(fabs(va(h,x3)-1)<.0001);
|
||||
assert(fabs(va(h,x1)+1)<.0001);
|
||||
assert(abs(va(h,x2)-1)<.0001);
|
||||
assert(abs(va(h,x3)-1)<.0001);
|
||||
assert(abs(va(h,x1)+1)<.0001);
|
||||
H h2=ch(tab2+1,tab2+3,x1,CGAL::ON_POSITIVE_SIDE);
|
||||
assert(hops(h2,x1));
|
||||
assert(os(h2,x1)==CGAL::ON_POSITIVE_SIDE);
|
||||
|
|
@ -354,20 +356,35 @@ void test2(){
|
|||
Sp sp = csp(tabz+0,tabz+3);
|
||||
P cent0=cos(sp);
|
||||
P cent1=cos(tabz+0,tabz+3);
|
||||
assert(fabs(cent0[0]-2)<.0001);
|
||||
assert(fabs(cent0[1]+3)<.0001);
|
||||
assert(fabs(cent1[0]-2)<.0001);
|
||||
assert(fabs(cent1[1]+3)<.0001);
|
||||
assert(fabs(sp.squared_radius()-25)<.0001);
|
||||
assert(abs(cent0[0]-2)<.0001);
|
||||
assert(abs(cent0[1]+3)<.0001);
|
||||
assert(abs(cent1[0]-2)<.0001);
|
||||
assert(abs(cent1[1]+3)<.0001);
|
||||
assert(abs(sp.squared_radius()-25)<.0001);
|
||||
#if 1
|
||||
// Fails for an exact kernel
|
||||
P psp0=ps(sp,0);
|
||||
P psp1=ps(sp,1);
|
||||
P psp2=ps(sp,2);
|
||||
assert(!ed(psp0,psp1));
|
||||
assert(!ed(psp0,psp2));
|
||||
assert(!ed(psp2,psp1));
|
||||
assert(fabs(sd(cent0,psp0)-25)<.0001);
|
||||
assert(fabs(sd(cent0,psp1)-25)<.0001);
|
||||
assert(fabs(sd(cent0,psp2)-25)<.0001);
|
||||
assert(abs(sd(cent0,psp0)-25)<.0001);
|
||||
assert(abs(sd(cent0,psp1)-25)<.0001);
|
||||
assert(abs(sd(cent0,psp2)-25)<.0001);
|
||||
#endif
|
||||
P x2py1 = tp(x2,y1);
|
||||
assert(x2py1[1]==-2);
|
||||
WP tw[]={cwp(cp(5,0),1.5),cwp(cp(2,std::sqrt(3)),1),cwp(cp(2,-std::sqrt(3)),1)};
|
||||
WP xw=pc(tw+0,tw+3);
|
||||
assert(abs(pod(xw,tw[0]))<.0001);
|
||||
assert(abs(pod(xw,tw[1]))<.0001);
|
||||
assert(abs(pod(xw,tw[2]))<.0001);
|
||||
assert(pdw(xw)[0]<2.95);
|
||||
assert(pdw(xw)[0]>2.5);
|
||||
assert(pw(xw)<2.95);
|
||||
assert(pw(xw)>2.5);
|
||||
|
||||
|
||||
P tl=cp(2,5);
|
||||
P br=cp(4,-1);
|
||||
|
|
@ -483,6 +500,7 @@ void test3(){
|
|||
PD pd Kinit(point_dimension_d_object);
|
||||
AI ai Kinit(affinely_independent_d_object);
|
||||
SBDS sbds Kinit(side_of_bounded_sphere_d_object);
|
||||
using std::abs;
|
||||
P a; // Triangulation needs this :-(
|
||||
a=cp(2,3,4);
|
||||
assert(pd(a)==3);
|
||||
|
|
@ -506,7 +524,7 @@ void test3(){
|
|||
std::cout << *i << ' ';
|
||||
std::cout << '\n';
|
||||
P e=cp(-2,3,0);
|
||||
assert(fabs(sd(e,a)-32)<.0001);
|
||||
assert(abs(sd(e,a)-32)<.0001);
|
||||
P tab[]={a,b,c,d,e};
|
||||
std::cout << po (&tab[0],tab+4) << ' ';
|
||||
std::cout << sos(&tab[0],tab+5) << ' ';
|
||||
|
|
|
|||
Loading…
Reference in New Issue