traits class now derives from template argument (meant to be a model of Kernel)

cleaning of useless types and includes
cleaning of names (Euclidean vs hyperbolic)
This commit is contained in:
Monique Teillaud 2016-08-03 16:55:14 +02:00
parent 706195c3ee
commit 61ded8fc1e
3 changed files with 107 additions and 131 deletions

View File

@ -6,10 +6,30 @@ using Triangulation_face_base_with_info_2<Hyperbolic_face_info_2>
in order to allow users to use
Triangulation_face_base_with_info_2 to add info in their faces
operator == for triangulations
add operator == for triangulations
radius should be 1 !!!
** clean approximations
the construction of the (hyperbolic) segment should not be approximated in the traits
the approximation should be done for the demo only
similar: clean find_intersection
(using the circular kernel will do)
fix construct_circumcenter. no approx allowed
(again, CK will do)
CK, or at least Cartesian with sqrt (?)
** demo
create an adapted Graphicsitem that does not require finite_* stuff. Replace by hyperbolic_*
=> understand apply_to_range
the graphicsitem should also not require Segment_2 or Line_segment_2 (does it?)
========== code
--- sqrt
@ -27,6 +47,7 @@ because Do_intersect is in the Circular_kernel
Done. CGAL::do_intersect is a solution.
No need for the Circular_kernel.
--> (MT) wrong for constrcutions. Approximations are used in several places.
--- iterators
- Finite_faces_iterator should return only faces marked HYPERBOLIC

View File

@ -78,10 +78,11 @@ private:
};
template < class Gt,
class Tds = Triangulation_data_structure_2 <
class Tds = Triangulation_data_structure_2 <
Triangulation_vertex_base_2<Gt>,
Triangulation_face_base_with_info_2<Hyperbolic_face_info_2, Gt> > >
class Hyperbolic_Delaunay_triangulation_2 : public Delaunay_triangulation_2<Gt,Tds>
class Hyperbolic_Delaunay_triangulation_2
: public Delaunay_triangulation_2<Gt,Tds>
{
public:
typedef Hyperbolic_Delaunay_triangulation_2<Gt, Tds> Self;
@ -113,7 +114,7 @@ public:
typedef Gt Geom_traits;
typedef typename Geom_traits::FT FT;
typedef typename Geom_traits::Point_2 Point;
typedef typename Geom_traits::Segment_2 Segment;
typedef typename Geom_traits::Hyperbolic_segment_2 Segment;
/*
#ifndef CGAL_CFG_USING_BASE_MEMBER_BUG_2

View File

@ -21,15 +21,6 @@
#ifndef CGAL_HYPERBOLIC_TRIANGULATION_TRAITS_2_H
#define CGAL_HYPERBOLIC_TRIANGULATION_TRAITS_2_H
#include <CGAL/Point_2.h>
#include <CGAL/Segment_2.h>
#include <CGAL/Triangle_2.h>
#include <CGAL/Line_2.h>
#include <CGAL/Ray_2.h>
#include <CGAL/predicates_on_points_2.h>
#include <CGAL/basic_constructions_2.h>
#include <CGAL/distance_predicates_2.h>
#include <CGAL/Regular_triangulation_filtered_traits_2.h>
#include "boost/tuple/tuple.hpp"
#include "boost/variant.hpp"
@ -37,46 +28,56 @@
namespace CGAL {
template < class R >
class Hyperbolic_triangulation_traits_2 {
class Hyperbolic_triangulation_traits_2
: public R
{
public:
typedef Hyperbolic_triangulation_traits_2<R> Self;
typedef typename R::FT FT;
typedef R Kernel;
typedef R Rep;
typedef typename R::RT RT;
typedef typename R::Point_2 Point_2;
typedef typename R::Vector_2 Vector_2;
typedef typename R::Triangle_2 Triangle_2;
typedef typename R::Line_2 Line_2;
typedef typename R::Ray_2 Ray_2;
typedef typename R::Circle_2 Circle_2;
typedef typename R::Vector_3 Vector_3;
typedef typename R::Point_3 Point_3;
typedef boost::tuple<Circle_2, Point_2, Point_2> Arc_2;
typedef typename R::Segment_2 Euclidean_segment_2; //only used internally here
typedef boost::variant<Arc_2, Euclidean_segment_2> Hyperbolic_segment_2;
typedef typename R::Less_x_2 Less_x_2;
typedef typename R::Less_y_2 Less_y_2;
typedef typename R::Compare_x_2 Compare_x_2;
typedef typename R::Compare_y_2 Compare_y_2;
typedef typename R::Orientation_2 Orientation_2;
typedef typename R::Side_of_oriented_circle_2 Side_of_oriented_circle_2;
typedef typename R::Construct_bisector_2 Construct_bisector_2;
typedef typename R::Compare_distance_2 Compare_distance_2;
typedef typename R::Construct_triangle_2 Construct_triangle_2;
typedef typename R::Construct_direction_2 Construct_direction_2;
typedef typename R::Angle_2 Angle_2;
typedef typename R::Construct_midpoint_2 Construct_midpoint_2;
typedef typename R::Compute_squared_distance_2 Compute_squared_distance_2;
// only kept for demo to please T2graphicsitems
typedef Euclidean_segment_2 Line_segment_2;
typedef Hyperbolic_segment_2 Segment_2;
typedef typename R::Iso_rectangle_2 Iso_rectangle_2;
typedef typename R::Circle_2 Circle_2;
// the following types are only used internally in this traits class,
// so they need not be documented, and they don't need _object()
typedef typename R::Collinear_2 Euclidean_collinear_2;
typedef typename R::Construct_bisector_2 Construct_Euclidean_bisector_2;
typedef typename R::Construct_midpoint_2 Construct_Euclidean_midpoint_2;
typedef typename R::Compute_squared_distance_2 Compute_squared_Euclidean_distance_2;
typedef typename R::Line_2 Euclidean_line_2;
typedef typename R::Vector_2 Vector_2;
// used by Is_hyperbolic
typedef typename R::Vector_3 Vector_3;
typedef typename R::Point_3 Point_3;
typedef boost::tuple<Circle_2, Point_2, Point_2> Arc_2;
typedef typename R::Segment_2 Line_segment_2;
typedef boost::variant<Arc_2, Line_segment_2> Segment_2;
// MT useless?
// typedef Hyperbolic_triangulation_traits_2<R> Self;
// typedef typename R::RT RT;
// typedef R Kernel;
// typedef R Rep;
// typedef typename R::Triangle_2 Triangle_2;
// typedef typename R::Line_2 Line_2;
// typedef typename R::Ray_2 Ray_2; // why would we need Eucldean rays??
// typedef typename R::Iso_rectangle_2 Iso_rectangle_2;
// typedef typename R::Angle_2 Angle_2;
typedef typename R::Line_2 Euclidean_line_2;
// typedef typename R::Less_x_2 Less_x_2;
// typedef typename R::Less_y_2 Less_y_2;
// typedef typename R::Compare_distance_2 Compare_distance_2;
// typedef typename R::Construct_triangle_2 Construct_triangle_2;
// typedef typename R::Construct_direction_2 Construct_direction_2;
private:
// Poincaré disk
@ -88,14 +89,6 @@ public:
return _unit_circle;
}
Angle_2
angle_2_object() const
{ return Angle_2(); }
Compute_squared_distance_2
compute_squared_distance_2_object() const
{ return Compute_squared_distance_2(); }
class Construct_segment_2
{
typedef typename CGAL::Regular_triangulation_filtered_traits_2<R> Regular_geometric_traits_2;
@ -108,11 +101,10 @@ public:
{
}
Segment_2 operator()(const Point_2& p, const Point_2& q) const
Hyperbolic_segment_2 operator()(const Point_2& p, const Point_2& q) const
{
typedef typename R::Collinear_2 Collinear_2;
if(Collinear_2()(p, q, _unit_circle.center())){
return Line_segment_2(p, q);
if(Euclidean_collinear_2()(p, q, _unit_circle.center())){
return Euclidean_segment_2(p, q);
}
Weighted_point_2 wp(p);
@ -120,7 +112,7 @@ public:
Weighted_point_2 wo(_unit_circle.center(), _unit_circle.squared_radius());
Bare_point center = Construct_weighted_circumcenter_2()(wp, wo, wq);
FT radius = Compute_squared_distance_2()(p, center);
FT radius = Compute_squared_Euclidean_distance_2()(p, center);
Circle_2 circle( center, radius);
// uncomment!!!
@ -188,26 +180,6 @@ public:
Construct_circumcenter_2(_unit_circle);
}
Construct_midpoint_2
construct_midpoint_2_object() const
{ return Construct_midpoint_2(); }
//for natural_neighbor_coordinates_2
typedef typename R::FT FT;
typedef typename R::Equal_x_2 Equal_x_2;
typedef typename R::Compute_area_2 Compute_area_2;
Compute_area_2 compute_area_2_object () const
{
return Compute_area_2();
}
// for compatibility with previous versions
typedef Point_2 Point;
typedef Segment_2 Segment;
typedef Triangle_2 Triangle;
typedef Ray_2 Ray;
//typedef Line_2 Line;
Hyperbolic_triangulation_traits_2() :
_unit_circle(Point_2(0, 0), 1*1)
{}
@ -226,28 +198,20 @@ public:
return *this;
}
Less_x_2
less_x_2_object() const
{ return Less_x_2();}
Less_y_2
less_y_2_object() const
{ return Less_y_2();}
Compare_x_2
compare_x_2_object() const
compare_x_2_object() const
{ return Compare_x_2();}
Compare_y_2
compare_y_2_object() const
compare_y_2_object() const
{ return Compare_y_2();}
Orientation_2
orientation_2_object() const
orientation_2_object() const
{ return Orientation_2();}
Side_of_oriented_circle_2
side_of_oriented_circle_2_object() const
side_of_oriented_circle_2_object() const
{return Side_of_oriented_circle_2();}
Construct_circumcenter_2
@ -262,15 +226,15 @@ public:
Construct_hyperbolic_bisector_2(const Circle_2& unit_circle) :
_unit_circle(unit_circle) {}
Segment_2 operator()(Point_2 p, Point_2 q) const
Hyperbolic_segment_2 operator()(Point_2 p, Point_2 q) const
{
// If two points are almost of the same distance to the origin, then
// the bisector is supported by the circle of huge radius etc.
// This circle is computed inexactly.
// At present time, in this case the bisector is supported by the line.
Compute_squared_distance_2 dist = Compute_squared_distance_2();
Point origin = _unit_circle.center();
Compute_squared_Euclidean_distance_2 dist = Compute_squared_Euclidean_distance_2();
Point_2 origin = _unit_circle.center();
FT dif = dist(origin, p) - dist(origin, q);
FT eps = 0.0000000001;
@ -281,15 +245,15 @@ public:
//if(Compare_distance_2()(_unit_circle.center(), p, q) == EQUAL){
// TODO: calling R::Construct_bisector
Euclidean_line_2 l = Construct_bisector_2()(p, q);
Euclidean_line_2 l = Construct_Euclidean_bisector_2()(p, q);
// compute the ending points
std::pair<Point_2, Point_2> points = find_intersection(l);
// TODO: improve
Vector_2 v(points.first, points.second);
if(v*l.to_vector() > 0){
return Line_segment_2(points.first, points.second);
return Euclidean_segment_2(points.first, points.second);
}
return Line_segment_2(points.second, points.first);
return Euclidean_segment_2(points.second, points.first);
}
Circle_2 c = construct_supporting_circle(p, q);
@ -318,8 +282,8 @@ public:
FT radius = x*x + y*y - _unit_circle.squared_radius();
//improve
typename R::Line_2 l = typename R::Construct_bisector_2()(p, q);
Point_2 middle = Construct_midpoint_2()(p, q);
Euclidean_line_2 l = Construct_Euclidean_bisector_2()(p, q);
Point_2 middle = Construct_Euclidean_midpoint_2()(p, q);
Point_2 temp = middle + l.to_vector();
if(Orientation_2()(middle, temp, Point_2(x, y)) == ON_POSITIVE_SIDE){
return Circle_2(Point_2(x, y), radius, CLOCKWISE);
@ -377,19 +341,9 @@ public:
construct_hyperbolic_bisector_2_object() const
{ return Construct_hyperbolic_bisector_2(_unit_circle);}
Construct_bisector_2
construct_bisector_2_object() const
{return Construct_bisector_2();}
Compare_distance_2
compare_distance_2_object() const
{return Compare_distance_2();}
Construct_triangle_2 construct_triangle_2_object() const
{return Construct_triangle_2();}
Construct_direction_2 construct_direction_2_object() const
{return Construct_direction_2();}
Construct_Euclidean_bisector_2
construct_Euclidean_bisector_2_object() const
{return Construct_Euclidean_bisector_2();}
class Construct_ray_2
{
@ -397,9 +351,9 @@ public:
Construct_ray_2(Circle_2 c) :
_unit_circle(c) {}
Segment_2 operator()(Point_2 p, Segment_2 l) const
Hyperbolic_segment_2 operator()(Point_2 p, Hyperbolic_segment_2 l) const
{
if(typename R::Segment_2* s = boost::get<typename R::Segment_2>(&l)){
if(Euclidean_segment_2* s = boost::get<Euclidean_segment_2>(&l)){
return operator()(p, *s);
}
if(Arc_2* arc = boost::get<Arc_2>(&l)){
@ -411,12 +365,12 @@ public:
return *arc;
}
assert(false);
return Segment_2();
return Hyperbolic_segment_2();
}
Segment_2 operator()(Point_2 p, typename R::Segment_2 s) const
Hyperbolic_segment_2 operator()(Point_2 p, Euclidean_segment_2 s) const
{
return typename R::Segment_2(p, s.target());
return Euclidean_segment_2(p, s.target());
}
private:
@ -425,14 +379,14 @@ public:
};
Construct_ray_2 construct_ray_2_object() const
{return Construct_ray_2(_unit_circle);}
{return Construct_ray_2(_unit_circle);}
// For details see the rapport RR-8146
// For details see the JoCG paper (5:56-85, 2014)
class Is_hyperbolic
{
public:
bool operator() (const Point& p0, const Point& p1, const Point& p2) const
bool operator() (const Point_2& p0, const Point_2& p1, const Point_2& p2) const
{
Vector_3 v0 = Vector_3(p0.x()*p0.x() + p0.y()*p0.y(),
p1.x()*p1.x() + p1.y()*p1.y(),
@ -449,7 +403,7 @@ public:
return dt0*dt0 + dt1*dt1 - dt2*dt2 < 0;
}
bool operator() (const Point& p0, const Point& p1, const Point& p2, int& ind) const
bool operator() (const Point_2& p0, const Point_2& p1, const Point_2& p2, int& ind) const
{
if (this->operator()(p0, p1, p2) == false) {
ind = find_non_hyperbolic_edge(p0, p1, p2);
@ -461,7 +415,7 @@ public:
private:
// assume the face (p0, p1, p2) is non-hyperbolic
int find_non_hyperbolic_edge(const Point& p0, const Point& p1, const Point& p2) const
int find_non_hyperbolic_edge(const Point_2& p0, const Point_2& p1, const Point_2& p2) const
{
typedef typename R::Direction_2 Direction_2;