mirror of https://github.com/CGAL/cgal
Weighted_point type.
This commit is contained in:
parent
19f4c90954
commit
bfc5a33ac4
|
|
@ -0,0 +1,76 @@
|
|||
// 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_KD_TYPE_WP_H
|
||||
#define CGAL_KD_TYPE_WP_H
|
||||
#include <CGAL/NewKernel_d/store_kernel.h>
|
||||
#include <boost/iterator/counting_iterator.hpp>
|
||||
namespace CGAL {
|
||||
template <class R_> class Weighted_point {
|
||||
typedef typename Get_type<R_, FT_tag>::type FT_;
|
||||
typedef typename Get_type<R_, Point_tag>::type Point_;
|
||||
Point_ c_;
|
||||
FT_ w_;
|
||||
|
||||
public:
|
||||
Weighted_point(Point_ const&p, FT_ const&w): c_(p), w_(w) {}
|
||||
// TODO: Add a piecewise constructor?
|
||||
|
||||
Point_ const& point()const{return c_;}
|
||||
FT_ const& weight()const{return w_;}
|
||||
};
|
||||
|
||||
namespace CartesianDKernelFunctors {
|
||||
template <class R_> struct Construct_weighted_point : Store_kernel<R_> {
|
||||
CGAL_FUNCTOR_INIT_STORE(Construct_weighted_point)
|
||||
typedef typename Get_type<R_, Weighted_point_tag>::type result_type;
|
||||
typedef typename Get_type<R_, Point_tag>::type Point;
|
||||
typedef typename Get_type<R_, FT_tag>::type FT;
|
||||
result_type operator()(Point const&a, FT const&b)const{
|
||||
return result_type(a,b);
|
||||
}
|
||||
};
|
||||
|
||||
template <class R_> struct Point_drop_weight {
|
||||
CGAL_FUNCTOR_INIT_IGNORE(Point_drop_weight)
|
||||
typedef typename Get_type<R_, Weighted_point_tag>::type argument_type;
|
||||
typedef typename Get_type<R_, Point_tag>::type const& result_type;
|
||||
|
||||
result_type operator()(argument_type const&s)const{
|
||||
return s.point();
|
||||
}
|
||||
};
|
||||
|
||||
template <class R_> struct Point_weight {
|
||||
CGAL_FUNCTOR_INIT_IGNORE(Point_weight)
|
||||
typedef typename Get_type<R_, Weighted_point_tag>::type argument_type;
|
||||
typedef typename Get_type<R_, FT_tag>::type const& result_type;
|
||||
|
||||
result_type operator()(argument_type const&s)const{
|
||||
return s.weight();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
CGAL_KD_DEFAULT_TYPE(Weighted_point_tag,(CGAL::Weighted_point<K>),(Point_tag),());
|
||||
CGAL_KD_DEFAULT_FUNCTOR(Construct_ttag<Weighted_point_tag>,(CartesianDKernelFunctors::Construct_weighted_point<K>),(Weighted_point_tag,Point_tag),());
|
||||
CGAL_KD_DEFAULT_FUNCTOR(Point_drop_weight_tag,(CartesianDKernelFunctors::Point_drop_weight<K>),(Weighted_point_tag,Point_tag),());
|
||||
CGAL_KD_DEFAULT_FUNCTOR(Point_weight_tag,(CartesianDKernelFunctors::Point_weight<K>),(Weighted_point_tag,Point_tag),());
|
||||
} // namespace CGAL
|
||||
#endif
|
||||
|
|
@ -156,6 +156,7 @@ namespace CGAL {
|
|||
DECL_OBJ(Iso_box, Object);
|
||||
DECL_OBJ(Bbox, Object);
|
||||
DECL_OBJ(Aff_transformation, Object);
|
||||
DECL_OBJ(Weighted_point, Object);
|
||||
#undef DECL_OBJ_
|
||||
#undef DECL_OBJ
|
||||
|
||||
|
|
@ -197,6 +198,7 @@ namespace CGAL {
|
|||
DECL_COMPUTE(Scalar_product);
|
||||
DECL_COMPUTE(Hyperplane_translation);
|
||||
DECL_COMPUTE(Value_at);
|
||||
DECL_COMPUTE(Point_weight);
|
||||
#undef DECL_COMPUTE
|
||||
|
||||
#define DECL_ITER_OBJ(X,Y,Z,C) struct X##_tag {}; \
|
||||
|
|
@ -246,6 +248,7 @@ namespace CGAL {
|
|||
DECL_CONSTRUCT(Translated_point,Point);
|
||||
DECL_CONSTRUCT(Point_to_vector,Vector);
|
||||
DECL_CONSTRUCT(Vector_to_point,Point);
|
||||
DECL_CONSTRUCT(Point_drop_weight,Point);
|
||||
#undef DECL_CONSTRUCT
|
||||
#if 0
|
||||
#define DECL_ITER_CONSTRUCT(X,Y) struct X##_tag {}; \
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include <CGAL/Gmpq.h>
|
||||
#include <CGAL/Interval_nt.h>
|
||||
#include <iostream>
|
||||
#include <CGAL/NewKernel_d/Types/Weighted_point.h>
|
||||
|
||||
template<class>void marc_use(){}
|
||||
#define USE_TYPE(T) marc_use<T>()
|
||||
|
|
@ -390,6 +391,7 @@ void test3(){
|
|||
P x4=cp(0,0,1);
|
||||
P x5=cp(0,0,0);
|
||||
P x6=cp(0,0,-1);
|
||||
assert(!ed(x1,x2));
|
||||
P tab2[]={x1,x2,x3,x4,x5};
|
||||
assert(po(tab2+0,tab2+4)==CGAL::POSITIVE);
|
||||
assert(sos(tab2+0,tab2+4,x5)==CGAL::ON_POSITIVE_SIDE);
|
||||
|
|
@ -436,6 +438,17 @@ void test3(){
|
|||
assert(ifsos(fozn, tz+0, tz+3, tz[4]) == CGAL::ON_NEGATIVE_SIDE);
|
||||
assert(ifsos(fozp, tz+0, tz+3, tz[5]) == CGAL::ON_NEGATIVE_SIDE);
|
||||
assert(ifsos(fozn, tz+0, tz+3, tz[5]) == CGAL::ON_POSITIVE_SIDE);
|
||||
|
||||
typedef typename CGAL::Get_type<K1, CGAL::Weighted_point_tag>::type WP;
|
||||
typedef typename CGAL::Get_functor<K1, CGAL::Construct_ttag<CGAL::Weighted_point_tag> >::type CWP;
|
||||
typedef typename CGAL::Get_functor<K1, CGAL::Point_drop_weight_tag>::type PDW;
|
||||
typedef typename CGAL::Get_functor<K1, CGAL::Point_weight_tag>::type PW;
|
||||
CWP cwp (k);
|
||||
PDW pdw (k);
|
||||
PW pw (k);
|
||||
WP wp = cwp (x1, 2);
|
||||
assert (pw(wp) == 2);
|
||||
assert (ed(pdw(wp), x1));
|
||||
}
|
||||
template struct CGAL::Epick_d<CGAL::Dimension_tag<2> >;
|
||||
template struct CGAL::Epick_d<CGAL::Dimension_tag<3> >;
|
||||
|
|
|
|||
Loading…
Reference in New Issue