Improve reader sanity

This commit is contained in:
Mael Rouxel-Labbé 2019-03-15 13:42:20 +01:00
parent e48bed20cc
commit 8648478b9a
10 changed files with 2718 additions and 2675 deletions

View File

@ -1,24 +1,22 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_sphere_2.h> #include <CGAL/Delaunay_triangulation_sphere_2.h>
#include <CGAL/Delaunay_triangulation_sphere_traits_2.h> #include <CGAL/Delaunay_triangulation_sphere_traits_2.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_sphere_traits_2<K> Traits;
typedef CGAL::Delaunay_triangulation_sphere_2<Traits> DToS2; typedef CGAL::Delaunay_triangulation_sphere_traits_2<K> Traits;
typedef CGAL::Delaunay_triangulation_sphere_2<Traits> DToS2;
int main() int main()
{ {
std::vector<K::Point_3> points; std::vector<K::Point_3> points;
points.push_back( K::Point_3(2,1,1) ); points.push_back(K::Point_3(2,1,1));
points.push_back( K::Point_3(-2,1,1) ); points.push_back(K::Point_3(-2,1,1));
points.push_back( K::Point_3(1,2,1) ); points.push_back(K::Point_3(1,2,1));
points.push_back( K::Point_3(1,-2,1) ); points.push_back(K::Point_3(1,-2,1));
Traits traits(K::Point_3(1,1,1)); Traits traits(K::Point_3(1,1,1));
DToS2 dtos(traits); DToS2 dtos(traits);
dtos.insert(points.begin(),points.end()); dtos.insert(points.begin(), points.end());
} }

View File

@ -1,20 +1,22 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_sphere_2.h> #include <CGAL/Delaunay_triangulation_sphere_2.h>
#include <CGAL/Projection_sphere_traits_3.h> #include <CGAL/Projection_sphere_traits_3.h>
#include <boost/iterator/transform_iterator.hpp> #include <boost/iterator/transform_iterator.hpp>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Projection_sphere_traits_3<K> Projection_traits; typedef CGAL::Projection_sphere_traits_3<K> Projection_traits;
typedef CGAL::Delaunay_triangulation_sphere_2<Projection_traits> Projected_DToS2; typedef CGAL::Delaunay_triangulation_sphere_2<Projection_traits> Projected_DToS2;
int main() int main()
{ {
std::vector<K::Point_3> points; std::vector<K::Point_3> points;
points.push_back( K::Point_3(3,1,1) ); points.push_back(K::Point_3(3,1,1));
points.push_back( K::Point_3(-8,1,1) ); points.push_back(K::Point_3(-8,1,1));
points.push_back( K::Point_3(1,2,1) ); points.push_back(K::Point_3(1,2,1));
points.push_back( K::Point_3(1,-2,1) ); points.push_back(K::Point_3(1,-2,1));
Projection_traits traits(K::Point_3(1,1,1)); Projection_traits traits(K::Point_3(1,1,1));
Projected_DToS2 dtos(traits); Projected_DToS2 dtos(traits);
@ -22,11 +24,7 @@ int main()
Projection_traits::Construct_projected_point_3 cst = Projection_traits::Construct_projected_point_3 cst =
traits.construct_projected_point_3_object(); traits.construct_projected_point_3_object();
dtos.insert(boost::make_transform_iterator(points.begin(), cst),
dtos.insert( boost::make_transform_iterator(points.end(), cst)
boost::make_transform_iterator(points.begin(), cst), );
boost::make_transform_iterator(points.end(), cst)
);
} }

View File

@ -14,7 +14,7 @@
// //
// $URL$ // $URL$
// $Id$ // $Id$
// // SPDX-License-Identifier: GPL-3.0+
// //
// Author(s) : Claudia Werner, Mariette Yvinec // Author(s) : Claudia Werner, Mariette Yvinec
@ -26,26 +26,28 @@
namespace CGAL { namespace CGAL {
template <class Gt, class Fb = Triangulation_face_base_sphere_2<Gt> > template < class Gt,
class Fb = Triangulation_face_base_sphere_2<Gt> >
class Constrained_triangulation_face_base_sphere_2 class Constrained_triangulation_face_base_sphere_2
: public Fb : public Fb
{ {
typedef Fb Base; typedef Fb Base;
typedef typename Fb::Triangulation_data_structure TDS; typedef typename Fb::Triangulation_data_structure TDS;
public: public:
typedef Gt Geom_traits; typedef Gt Geom_traits;
typedef TDS Triangulation_data_structure; typedef TDS Triangulation_data_structure;
typedef typename TDS::Vertex_handle Vertex_handle;
typedef typename TDS::Face_handle Face_handle; typedef typename TDS::Vertex_handle Vertex_handle;
typedef typename TDS::Face_handle Face_handle;
template < typename TDS2 > template < typename TDS2 >
struct Rebind_TDS { struct Rebind_TDS
typedef typename Fb::template Rebind_TDS<TDS2>::Other Fb2; {
typedef Constrained_triangulation_face_base_sphere_2<Gt,Fb2> Other; typedef typename Fb::template Rebind_TDS<TDS2>::Other Fb2;
typedef Constrained_triangulation_face_base_sphere_2<Gt, Fb2> Other;
}; };
protected: protected:
bool C[3]; bool C[3];
@ -53,75 +55,72 @@ public:
Constrained_triangulation_face_base_sphere_2() Constrained_triangulation_face_base_sphere_2()
: Base() : Base()
{ {
set_constraints(false,false,false); set_constraints(false, false, false);
} }
Constrained_triangulation_face_base_sphere_2(Vertex_handle v0, Constrained_triangulation_face_base_sphere_2(Vertex_handle v0,
Vertex_handle v1, Vertex_handle v1,
Vertex_handle v2) Vertex_handle v2)
: Base(v0,v1,v2) : Base(v0, v1, v2)
{ {
set_constraints(false,false,false); set_constraints(false, false, false);
} }
Constrained_triangulation_face_base_sphere_2(Vertex_handle v0, Constrained_triangulation_face_base_sphere_2(Vertex_handle v0,
Vertex_handle v1, Vertex_handle v1,
Vertex_handle v2, Vertex_handle v2,
Face_handle n0, Face_handle n0,
Face_handle n1, Face_handle n1,
Face_handle n2) Face_handle n2)
: Base(v0,v1,v2,n0,n1,n2) : Base(v0, v1, v2, n0, n1, n2)
{ {
set_constraints(false,false,false); set_constraints(false, false, false);
} }
Constrained_triangulation_face_base_sphere_2(Vertex_handle v0, Constrained_triangulation_face_base_sphere_2(Vertex_handle v0,
Vertex_handle v1, Vertex_handle v1,
Vertex_handle v2, Vertex_handle v2,
Face_handle n0, Face_handle n0,
Face_handle n1, Face_handle n1,
Face_handle n2, Face_handle n2,
bool c0, bool c0,
bool c1, bool c1,
bool c2 ) bool c2)
: Base(v0,v1,v2,n0,n1,n2) : Base(v0, v1, v2, n0, n1, n2)
{ {
set_constraints(c0,c1,c2); set_constraints(c0, c1, c2);
} }
bool is_constrained(int i) const ; bool is_constrained(int i) const ;
void set_constraints(bool c0, bool c1, bool c2) ; void set_constraints(bool c0, bool c1, bool c2) ;
void set_constraint(int i, bool b); void set_constraint(int i, bool b);
void reorient(); void reorient();
void ccw_permute(); void ccw_permute();
void cw_permute(); void cw_permute();
}; };
template <class Gt, class Fb> template <class Gt, class Fb>
inline void inline void
Constrained_triangulation_face_base_sphere_2<Gt,Fb>:: Constrained_triangulation_face_base_sphere_2<Gt, fb>::
set_constraints(bool c0, bool c1, bool c2) set_constraints(bool c0, bool c1, bool c2)
{ {
C[0]=c0; C[0] = c0;
C[1]=c1; C[1] = c1;
C[2]=c2; C[2] = c2;
} }
template <class Gt, class Fb> template <class Gt, class Fb>
inline void inline void
Constrained_triangulation_face_base_sphere_2<Gt,Fb>:: Constrained_triangulation_face_base_sphere_2<Gt, fb>::
set_constraint(int i, bool b) set_constraint(int i, bool b)
{ {
CGAL_triangulation_precondition( i == 0 || i == 1 || i == 2); CGAL_triangulation_precondition(i == 0 || i == 1 || i == 2);
C[i] = b; C[i] = b;
} }
template <class Gt, class Fb> template <class Gt, class Fb>
inline bool inline bool
Constrained_triangulation_face_base_sphere_2<Gt,Fb>:: Constrained_triangulation_face_base_sphere_2<Gt, fb>::
is_constrained(int i) const is_constrained(int i) const
{ {
return(C[i]); return(C[i]);
@ -129,31 +128,31 @@ is_constrained(int i) const
template <class Gt, class Fb> template <class Gt, class Fb>
inline void inline void
Constrained_triangulation_face_base_sphere_2<Gt,Fb>:: Constrained_triangulation_face_base_sphere_2<Gt, fb>::
reorient() reorient()
{ {
Base::reorient(); Base::reorient();
set_constraints(C[1],C[0],C[2]); set_constraints(C[1], c[0], c[2]);
} }
template <class Gt, class Fb> template <class Gt, class Fb>
inline void inline void
Constrained_triangulation_face_base_sphere_2<Gt,Fb>:: Constrained_triangulation_face_base_sphere_2<Gt, fb>::
ccw_permute() ccw_permute()
{ {
Base::ccw_permute(); Base::ccw_permute();
set_constraints(C[2],C[0],C[1]); set_constraints(C[2], c[0], c[1]);
} }
template <class Gt, class Fb> template <class Gt, class Fb>
inline void inline void
Constrained_triangulation_face_base_sphere_2<Gt,Fb>:: Constrained_triangulation_face_base_sphere_2<Gt, fb>::
cw_permute() cw_permute()
{ {
Base::cw_permute(); Base::cw_permute();
set_constraints(C[1],C[2],C[0]); set_constraints(C[1], c[2], c[0]);
} }
} //namespace CGAL } // namespace CGAL
#endif //CGAL_CONSTRAINED_TRIANGULATION_FACE_BASE_SPHERE_2_H #endif //CGAL_CONSTRAINED_TRIANGULATION_FACE_BASE_SPHERE_2_H

View File

@ -1,12 +1,27 @@
// Author(s) : // Copyright (c) 1997, 2012, 2019 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// You can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation,
// either version 3 of the Licenxse, 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$
// SPDX-License-Identifier: GPL-3.0+
//
// Author(s) : Mariette Yvinec, Claudia Werner
#ifndef CGAL_DELAUNAY_TRIANGULATION_SPHERE_FILTERED_TRAITS_2_H #ifndef CGAL_DELAUNAY_TRIANGULATION_SPHERE_FILTERED_TRAITS_2_H
#define CGAL_DELAUNAY_TRIANGULATION_SPHERE_FILTERED_TRAITS_2_H #define CGAL_DELAUNAY_TRIANGULATION_SPHERE_FILTERED_TRAITS_2_H
#include <CGAL/basic.h>
#include <CGAL/Delaunay_triangulation_sphere_traits_2.h> #include <CGAL/Delaunay_triangulation_sphere_traits_2.h>
#include <CGAL/Filtered_predicate.h>
//#include <CGAL/static_in_cone_ntC3.h>
namespace CGAL { namespace CGAL {
@ -34,14 +49,11 @@ struct Delaunay_weighted_converter_2
return Target_wp(Converter::operator()(wp.point()), return Target_wp(Converter::operator()(wp.point()),
Converter::operator()(wp.weight())); Converter::operator()(wp.weight()));
}*/ }*/
Target_wp
operator()(const Source_wp &wp) const Target_wp operator()(const Source_wp &wp) cons { return Converter::operator()(wp); }
{
return Converter::operator()(wp);
}
}; };
/* /*
// The argument is supposed to be a Filtered_kernel like kernel. // The argument is supposed to be a Filtered_kernel like kernel.
template < typename K > template < typename K >
@ -99,7 +111,7 @@ public:
Delaunay_weighted_converter_2<C2F> > In_cone_3; Delaunay_weighted_converter_2<C2F> > In_cone_3;
Power_test_2 power_test_2_object() const Power_test_2 power_test_2_object() const
{ return Power_test_2();} { return Power_test_2(); }
Compare_power_distance_2 compare_power_distance_2_object() const Compare_power_distance_2 compare_power_distance_2_object() const
{ return Compare_power_distance_2(); } { return Compare_power_distance_2(); }
@ -112,7 +124,7 @@ public:
} }
Side_of_oriented_circle_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(); return Side_of_oriented_circle_2();
} }

View File

@ -1,211 +1,211 @@
// Copyright (c) 1997, 2012, 2019 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// You can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation,
// either version 3 of the Licenxse, 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$
// SPDX-License-Identifier: GPL-3.0+
//
// Author(s) : Mariette Yvinec, Claudia Werner
#ifndef CGAL_DELAUNAY_TRIANGULATION_SPHERE_TRAITS_2_H #ifndef CGAL_DELAUNAY_TRIANGULATION_SPHERE_TRAITS_2_H
#define CGAL_DELAUNAY_TRIANGULATION_SPHERE_TRAITS_2_H #define CGAL_DELAUNAY_TRIANGULATION_SPHERE_TRAITS_2_H
#include <CGAL/number_utils_classes.h> #include <CGAL/enum.h>
#include <CGAL/triangulation_assertions.h>
#include <CGAL/Kernel_traits.h>
#include <CGAL/Line_2.h>
#include <CGAL/Ray_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/triangulation_assertions.h>
#include <CGAL/Segment_2_Segment_2_intersection.h>
namespace CGAL { namespace CGAL {
template <typename K > template < typename K >
class Power_test_2 class Power_test_2
{ {
public: public:
typedef typename K::Point_2 Point_2; typedef typename K::Point_2 Point_2;
typedef typename K::Oriented_side Oriented_side; typedef typename K::Oriented_side Oriented_side;
typedef typename K::Comparison_result Comparison_result; typedef typename K::Comparison_result Comparison_result;
Power_test_2(const Point_2& sphere); Power_test_2(const Point_2& sphere);
Oriented_side operator() (const Point_2& p, Oriented_side operator()(const Point_2& p,
const Point_2& q, const Point_2& q,
const Point_2& r, const Point_2& r,
const Point_2& s) const const Point_2& s) const
{ return orientation(p,q,r,s); }
Oriented_side operator() (const Point_2& p,
const Point_2& q,
const Point_2& r) const
{ {
return -coplanar_orientation(p,q,_sphere,r); return orientation(p, q, r, s);
} }
Oriented_side operator()(const Point_2& p,
Oriented_side operator() (const Point_2& p, const Point_2& q,
const Point_2& q) const const Point_2& r) const
{ {
Comparison_result pq=compare_xyz(p,q); return -coplanar_orientation(p, q,_sphere, r);
}
if(pq==EQUAL){ Oriented_side operator()(const Point_2& p,
const Point_2& q) const
{
Comparison_result pq = compare_xyz(p, q);
if(pq == EQUAL)
return ON_ORIENTED_BOUNDARY; return ON_ORIENTED_BOUNDARY;
}
Comparison_result sq=compare_xyz(_sphere,q); Comparison_result sq = compare_xyz(_sphere, q);
if(pq==sq){ if(pq == sq)
return ON_POSITIVE_SIDE; return ON_POSITIVE_SIDE;
}
return ON_NEGATIVE_SIDE; return ON_NEGATIVE_SIDE;
} }
public:
typedef Oriented_side result_type;
protected: public:
Point_2 _sphere; typedef Oriented_side result_type;
protected:
Point_2 _sphere;
}; };
template < typename K > template < typename K >
Power_test_2<K>:: Power_test_2<K>::
Power_test_2(const Point_2& sphere) Power_test_2(const Point_2& sphere)
: _sphere(sphere) : _sphere(sphere)
{} { }
template < typename K > template < typename K >
class Orientation_sphere_1 class Orientation_sphere_1
{ {
public: public:
typedef typename K::Point_2 Point_2; typedef typename K::Point_2 Point_2;
typedef typename K::Comparison_result Comparison_result; typedef typename K::Comparison_result Comparison_result;
typedef Comparison_result result_type;
Orientation_sphere_1(const Point_2& sphere); Orientation_sphere_1(const Point_2& sphere);
Comparison_result operator()(const Point_2& p, const Point_2& q) const Comparison_result operator()(const Point_2& p, const Point_2& q) const
{ return coplanar_orientation(_sphere,p,q);} {
return coplanar_orientation(_sphere, p, q);
}
Comparison_result operator()(const Point_2& p, const Point_2& q, const Point_2& r) const Comparison_result operator()(const Point_2& p, const Point_2& q, const Point_2& r) const
{ return coplanar_orientation(p,q,r,_sphere); } {
return coplanar_orientation(p, q, r, _sphere);
Comparison_result operator()(const Point_2& p, const Point_2& q, const Point_2& r,const Point_2& s) const }
{ return coplanar_orientation(p,q,r,s);}
Comparison_result operator()(const Point_2& p, const Point_2& q, const Point_2& r, const Point_2& s) const
{
return coplanar_orientation(p, q, r, s);
}
protected : protected :
Point_2 _sphere; Point_2 _sphere;
public:
typedef Comparison_result result_type;
}; };
template < typename K > template < typename K >
Orientation_sphere_1<K>:: Orientation_sphere_1<K>::
Orientation_sphere_1(const Point_2& sphere) Orientation_sphere_1(const Point_2& sphere)
: _sphere(sphere) : _sphere(sphere)
{} { }
template < typename K > template < typename K >
class Orientation_sphere_2 class Orientation_sphere_2
{ {
public: public:
typedef typename K::Point_2 Point_2; typedef typename K::Point_2 Point_2;
typedef typename K::Comparison_result Comparison_result; typedef typename K::Comparison_result Comparison_result;
typedef Comparison_result result_type; typedef Comparison_result result_type;
Orientation_sphere_2(const Point_2& sphere); Orientation_sphere_2(const Point_2& sphere);
Comparison_result operator()(const Point_2& p, const Point_2& q, Comparison_result operator()(const Point_2& p, const Point_2& q,
const Point_2& r) const const Point_2& r) const
{ return orientation(_sphere,p,q,r);} { return orientation(_sphere, p, q, r); }
Comparison_result operator()(const Point_2& p, const Point_2& q,
const Point_2& r, const Point_2 & s) const
{return orientation(p,q,r,s);}
Comparison_result operator()(const Point_2& p, const Point_2& q,
const Point_2& r, const Point_2& s) const
{ return orientation(p, q, r, s); }
protected : protected :
Point_2 _sphere; Point_2 _sphere;
}; };
template < typename K > template < typename K >
Orientation_sphere_2<K>:: Orientation_sphere_2<K>::
Orientation_sphere_2(const Point_2& sphere) Orientation_sphere_2(const Point_2& sphere)
: _sphere(sphere) : _sphere(sphere)
{} { }
template < typename K > template < typename K >
class Coradial_sphere_2 class Coradial_sphere_2
{ {
public: public:
typedef typename K::Point_2 Point_2; typedef typename K::Point_2 Point_2;
Coradial_sphere_2(const Point_2& sphere); typedef bool result_type;
bool operator()(const Point_2& p, const Point_2 q) const Coradial_sphere_2(const Point_2& sphere);
{
return collinear(_sphere,p,q) && bool operator()(const Point_2& p, const Point_2 q) const
( are_ordered_along_line(_sphere,p,q) || are_ordered_along_line(_sphere,q,p) ); {
} return collinear(_sphere, p, q) &&
(are_ordered_along_line(_sphere, p, q) ||
are_ordered_along_line(_sphere, q, p));
}
protected : protected :
Point_2 _sphere; Point_2 _sphere;
public:
typedef bool result_type;
}; };
template < typename K > template < typename K >
Coradial_sphere_2<K>:: Coradial_sphere_2<K>::
Coradial_sphere_2(const Point_2& sphere) Coradial_sphere_2(const Point_2& sphere)
: _sphere(sphere) : _sphere(sphere)
{} { }
template < typename K > template < typename K >
class Inside_cone_2 class Inside_cone_2
{ {
public: public:
typedef typename K::Point_2 Point_2; typedef typename K::Point_2 Point_2;
typedef bool result_type;
Inside_cone_2(const Point_2& sphere); Inside_cone_2(const Point_2& sphere);
bool operator()(const Point_2& p, const Point_2& q, const Point_2& r) const bool operator()(const Point_2& p, const Point_2& q, const Point_2& r) const
{ {
if( collinear(_sphere,p,r)||collinear(_sphere,q,r)||orientation(_sphere,p,q,r)!=COLLINEAR) if(collinear(_sphere, p, r) ||
return false; collinear(_sphere, q, r) ||
if( collinear(_sphere,p,q) ) orientation(_sphere, p, q, r) != COLLINEAR)
return true; return false;
return coplanar_orientation(_sphere,p,q,r) == ( POSITIVE==coplanar_orientation(_sphere,q,p,r) );
} if(collinear(_sphere, p, q))
return true;
return coplanar_orientation(_sphere, p, q, r) ==
(POSITIVE == coplanar_orientation(_sphere, q, p, r));
}
protected : protected :
Point_2 _sphere; Point_2 _sphere;
public:
typedef bool result_type;
}; };
template < typename K > template < typename K >
Inside_cone_2<K>:: Inside_cone_2<K>::
Inside_cone_2(const Point_2& sphere) Inside_cone_2(const Point_2& sphere)
: _sphere(sphere) : _sphere(sphere)
{} { }
template < class R > template < class R >
class Delaunay_triangulation_sphere_traits_2 class Delaunay_triangulation_sphere_traits_2
: public R : public R
{ {
public: public:
typedef typename R::Point_3 Point_2; typedef typename R::Point_3 Point_2;
typedef typename R::Point_3 Weighted_point_2; typedef typename R::Point_3 Weighted_point_2;
typedef typename R::Ray_3 Ray_2; typedef typename R::Ray_3 Ray_2;
@ -215,94 +215,77 @@ public:
typedef typename R::Construct_bisector_3 Construct_bisector_3; typedef typename R::Construct_bisector_3 Construct_bisector_3;
typedef typename R::Construct_segment_3 Construct_segment_3; typedef typename R::Construct_segment_3 Construct_segment_3;
typedef Delaunay_triangulation_sphere_traits_2<R> Self; typedef Delaunay_triangulation_sphere_traits_2<R> Self;
typedef CGAL::Power_test_2<Self> Power_test_2; typedef CGAL::Power_test_2<Self> Power_test_2;
typedef CGAL::Orientation_sphere_2<Self> Orientation_2; typedef CGAL::Orientation_sphere_2<Self> Orientation_2;
typedef CGAL::Coradial_sphere_2<Self> Coradial_sphere_2; typedef CGAL::Coradial_sphere_2<Self> Coradial_sphere_2;
typedef CGAL::Inside_cone_2<Self> Inside_cone_2; typedef CGAL::Inside_cone_2<Self> Inside_cone_2;
//typedef CGAL::Orientation_sphere_1<Self> Orientation_1; //typedef CGAL::Orientation_sphere_1<Self> Orientation_1;
typedef typename R::Coplanar_orientation_3 Orientation_1; typedef typename R::Coplanar_orientation_3 Orientation_1;
typedef typename R::Compute_squared_distance_3 Compute_squared_distance_2; typedef typename R::Compute_squared_distance_3 Compute_squared_distance_2;
typedef typename R::Compare_xyz_3 Compare_xyz_3; typedef typename R::Compare_xyz_3 Compare_xyz_3;
double _radius; typedef boost::true_type requires_test;
double _radius;
typedef boost::true_type requires_test; void set_radius(double a) { _radius = a; }
void set_radius(double a){_radius = a;}
Delaunay_triangulation_sphere_traits_2(const Point_2& sphere = Point_2(0,0,0));
Delaunay_triangulation_sphere_traits_2(const Point_2& sphere=Point_2(0,0,0));
Compare_xyz_3 Compare_xyz_3
compare_xyz_3_object() const compare_xyz_3_object() const
{return Compare_xyz_3();} { return Compare_xyz_3(); }
Compute_squared_distance_2 Compute_squared_distance_2
compute_squared_distance_2_object() const compute_squared_distance_2_object() const
{return Compute_squared_distance_2();} { return Compute_squared_distance_2(); }
Orientation_2 Orientation_2
orientation_2_object()const orientation_2_object() const
{return Orientation_2(_sphere);} { return Orientation_2(_sphere); }
Orientation_1 Orientation_1
orientation_1_object() const orientation_1_object() const
{return Orientation_1();} { return Orientation_1(); }
Power_test_2 Power_test_2
power_test_2_object() const power_test_2_object() const
{return Power_test_2(_sphere);} { return Power_test_2(_sphere); }
Coradial_sphere_2 Coradial_sphere_2
coradial_sphere_2_object() const coradial_sphere_2_object() const
{return Coradial_sphere_2(_sphere);} { return Coradial_sphere_2(_sphere); }
Inside_cone_2 Inside_cone_2
inside_cone_2_object() const inside_cone_2_object() const
{return Inside_cone_2(_sphere);} { return Inside_cone_2(_sphere); }
Construct_ray_3 construct_ray_2_object() const Construct_ray_3
{return Construct_ray_3();} construct_ray_2_object() const
{ return Construct_ray_3(); }
Construct_circumcenter_3 Construct_circumcenter_3
construct_circumcenter_2_object() const construct_circumcenter_2_object() const
{ return Construct_circumcenter_3();} { return Construct_circumcenter_3(); }
Construct_segment_3
construct_segment_2_object() const
{ return Construct_segment_3(); }
Construct_segment_3 Compute_squared_distance_2
construct_segment_2_object()const compute_squared_distance_3_object() const
{return Construct_segment_3();} { return Compute_squared_distance_2(); }
Compute_squared_distance_2 compute_squared_distance_3_object() const
{ return Compute_squared_distance_2(); }
protected : protected :
Point_2 _sphere; Point_2 _sphere;
}; };
template < class R > template < class R >
Delaunay_triangulation_sphere_traits_2<R> :: Delaunay_triangulation_sphere_traits_2<R> ::
Delaunay_triangulation_sphere_traits_2(const Point_2& sphere) Delaunay_triangulation_sphere_traits_2(const Point_2& sphere)
: _sphere(sphere) : _sphere(sphere)
{} { }
} // namespace CGAL
} //namespace CGAL
#endif // CGAL_Reg_TRIANGULATION_SPHERE_TRAITS_2_H #endif // CGAL_Reg_TRIANGULATION_SPHERE_TRAITS_2_H

View File

@ -1,231 +1,231 @@
// Copyright (c) 1997, 2012, 2019 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// You can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation,
// either version 3 of the Licenxse, 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$
// SPDX-License-Identifier: GPL-3.0+
//
// Author(s) : Mariette Yvinec, Claudia Werner
#ifndef CGAL_PROJECTION_SPHERE_TRAITS_3_H #ifndef CGAL_PROJECTION_SPHERE_TRAITS_3_H
#define CGAL_PROJECTION_SPHERE_TRAITS_3_H #define CGAL_PROJECTION_SPHERE_TRAITS_3_H
#include <CGAL/number_utils_classes.h>
#include <CGAL/triangulation_assertions.h>
#include <CGAL/Kernel_traits.h>
#include <CGAL/Delaunay_triangulation_sphere_traits_2.h> #include <CGAL/Delaunay_triangulation_sphere_traits_2.h>
namespace CGAL{template<typename K> #include <CGAL/triangulation_assertions.h>
#include <CGAL/number_utils_classes.h>
#include <CGAL/Kernel_traits.h>
namespace CGAL {
template<typename K>
class Projection_sphere_traits_3; class Projection_sphere_traits_3;
template < typename K> template < typename K>
class Projected_point class Projected_point
: public K::Point_3{ : public K::Point_3
{
public: public:
typedef typename K::Point_3 Base_point; typedef typename K::Point_3 Base_point;
Projected_point()
:Base_point(){}
Projected_point() : Base_point() { }
Projected_point(const Base_point &p, const typename K::Point_3& sphere_center) Projected_point(const Base_point& p,
:Base_point(p){compute_scale( p-(sphere_center-ORIGIN) );} const typename K::Point_3& sphere_center)
: Base_point(p)
{
public: compute_scale(p-(sphere_center-ORIGIN));
double _scale;
void scale(){return _scale;}
private:
void compute_scale(double x, double y, double z){
double tmp = x*x+y*y+z*z;
if (tmp == 0 )
_scale = 0;
else
_scale = 1/sqrt(tmp);
}
void compute_scale(const Base_point &p){
return compute_scale(p.x(), p.y(), p.z());
} }
};
//the following two different adaptors are necessary because the Predicates don not need _sphere
//compared to Predicates from Delaunay_sphere_traits
//adaptor for calling the Predicate_ with the points projected on the sphere
template < class K, class P, class Predicate_ >
class Traits_with_projection_adaptor {
public: public:
typedef Predicate_ Predicate; double _scale;
typedef typename P::Point_2 Point;
typedef typename K::Point_2 Base_point;
Traits_with_projection_adaptor(Base_point sphere, double radius):_radius(radius), _sphere(sphere){}
double _radius;
Base_point _sphere ;
typedef typename Predicate::result_type result_type;
result_type operator()(const Point& p0, const Point& p1)
{return Predicate(_sphere)(project(p0), project(p1));}
result_type operator()(const Point& p0, const Point& p1, const Point& p2)
{return Predicate(_sphere)(project(p0), project(p1), project(p2));}
result_type operator ()(const Point& p0, const Point& p1, const Point& p2, const Point& p3)
{return Predicate(_sphere)(project(p0), project(p1), project(p2), project(p3));}
result_type operator()(const Point& p0, const Point& p1, const Point& p2, const Point& p3, const Point& p4)
{return Predicate(_sphere)(project(p0), project(p1), project(p2), project(p3), project(p4));}
void scale() { return _scale; }
private: private:
Base_point project (const Point& p){ void compute_scale(double x, double y, double z)
double scale = _radius*p._scale; {
return Base_point(scale*p.x(), scale*p.y(), scale*p.z()); double tmp = x*x+y*y+z*z;
} if(tmp == 0)
_scale = 0;
else
_scale = 1 / sqrt(tmp);
}
void compute_scale(const Base_point& p)
{
return compute_scale(p.x(), p.y(), p.z());
}
};
// the following two different adaptors are necessary because the Predicates don not need _sphere
// compared to Predicates from Delaunay_sphere_traits
// adaptor for calling the Predicate_ with the points projected on the sphere
template < class K, class P, class Predicate_ >
class Traits_with_projection_adaptor
{
public:
typedef Predicate_ Predicate;
typedef typename P::Point_2 Point;
typedef typename K::Point_2 Base_point;
Traits_with_projection_adaptor(Base_point sphere, double radius) : _radius(radius), _sphere(sphere) { }
double _radius;
Base_point _sphere ;
typedef typename Predicate::result_type result_type;
result_type operator()(const Point& p0, const Point& p1)
{ return Predicate(_sphere)(project(p0), project(p1)); }
result_type operator()(const Point& p0, const Point& p1, const Point& p2)
{ return Predicate(_sphere)(project(p0), project(p1), project(p2)); }
result_type operator ()(const Point& p0, const Point& p1, const Point& p2, const Point& p3)
{ return Predicate(_sphere)(project(p0), project(p1), project(p2), project(p3)); }
result_type operator()(const Point& p0, const Point& p1, const Point& p2, const Point& p3, const Point& p4)
{ return Predicate(_sphere)(project(p0), project(p1), project(p2), project(p3), project(p4)); }
private:
Base_point project (const Point& p)
{
double scale = _radius * p._scale;
return Base_point(scale*p.x(), scale*p.y(), scale*p.z());
}
}; };
//adaptor for calling the Predicate_ with the points projected on the sphere for predicates from the Kernel //adaptor for calling the Predicate_ with the points projected on the sphere for predicates from the Kernel
template < class K, class P, class Predicate_ > template < class K, class P, class Predicate_ >
class Traits_with_projection_adaptorKernel { class Traits_with_projection_adaptorKernel
{
public: public:
typedef Predicate_ Predicate; typedef Predicate_ Predicate;
typedef typename P::Point_2 Point; typedef typename P::Point_2 Point;
typedef typename K::Point_3 Base_point; typedef typename K::Point_3 Base_point;
Traits_with_projection_adaptorKernel( double radius):_radius(radius){}
double _radius;
Base_point _sphere ;
typedef typename Predicate::result_type result_type; Traits_with_projection_adaptorKernel(double radius) : _radius(radius) { }
double _radius;
Base_point _sphere;
typedef typename Predicate::result_type result_type;
result_type operator()(const Point& p0, const Point& p1) result_type operator()(const Point& p0, const Point& p1)
{return Predicate()(project(p0), project(p1));} { return Predicate()(project(p0), project(p1)); }
result_type operator()(const Point& p0, const Point& p1, const Point& p2)
{ return Predicate()(project(p0), project(p1), project(p2)); }
result_type operator()(const Point& p0, const Point& p1, const Point& p2) result_type operator ()(const Point& p0, const Point& p1, const Point& p2, const Point& p3)
{return Predicate()(project(p0), project(p1), project(p2));} { return Predicate()(project(p0), project(p1), project(p2), project(p3)); }
result_type operator ()(const Point& p0, const Point& p1, const Point& p2, const Point& p3)
{return Predicate()(project(p0), project(p1), project(p2), project(p3));}
result_type operator()(const Point& p0, const Point& p1, const Point& p2, const Point& p3, const Point& p4)
{return Predicate()(project(p0), project(p1), project(p2), project(p3), project(p4));}
result_type operator()(const Point& p0, const Point& p1, const Point& p2, const Point& p3, const Point& p4)
{ return Predicate()(project(p0), project(p1), project(p2), project(p3), project(p4)); }
private: private:
Base_point project (const Point& p){ Base_point project (const Point& p)
double scale = _radius*p._scale; {
return Base_point(scale*p.x(), scale*p.y(), scale*p.z()); double scale = _radius * p._scale;
} return Base_point(scale*p.x(), scale*p.y(), scale*p.z());
}
}; };
template < class R > template < class R >
class Projection_sphere_traits_3 class Projection_sphere_traits_3
: public R : public R
{ {
protected: protected:
public: public:
double _radius; double _radius;
typedef Projection_sphere_traits_3<R> Self; typedef Projection_sphere_traits_3<R> Self;
typedef Delaunay_triangulation_sphere_traits_2<R> Base; typedef Delaunay_triangulation_sphere_traits_2<R> Base;
typedef typename Projected_point<R>::Projected_point Point_2; typedef typename Projected_point<R>::Projected_point Point_2;
typedef typename R::Point_3 Base_point; typedef typename R::Point_3 Base_point;
typedef Point_2 result_type; typedef Point_2 result_type;
typedef Traits_with_projection_adaptor<Base,Self,typename Base::Power_test_2> typedef Traits_with_projection_adaptor<Base, Self, typename Base::Power_test_2> Power_test_2;
Power_test_2; typedef Traits_with_projection_adaptor<Base, Self, typename Base::Orientation_2> Orientation_2;
typedef Traits_with_projection_adaptor<Base, Self,typename Base::Orientation_2> typedef Traits_with_projection_adaptor<Base, Self, typename Base::Coradial_sphere_2 > Coradial_sphere_2;
Orientation_2; typedef Traits_with_projection_adaptor<Base, Self, typename Base::Inside_cone_2 > Inside_cone_2;
typedef Traits_with_projection_adaptor<Base,Self, typename Base::Coradial_sphere_2 > typedef Traits_with_projection_adaptorKernel<R, Self, typename Base::Orientation_1 > Orientation_1;
Coradial_sphere_2; typedef Traits_with_projection_adaptorKernel<R, Self, typename Base ::Compute_squared_distance_2> Compute_squared_distance_2;
typedef Traits_with_projection_adaptor<Base,Self,typename Base::Inside_cone_2 > typedef Traits_with_projection_adaptorKernel<R, Self, typename Base::Compare_xyz_3> Compare_xyz_3;
Inside_cone_2;
typedef Traits_with_projection_adaptorKernel<R,Self,typename Base::Orientation_1 >
Orientation_1;
typedef Traits_with_projection_adaptorKernel<R, Self , typename Base ::Compute_squared_distance_2>
Compute_squared_distance_2;
typedef Traits_with_projection_adaptorKernel<R , Self, typename Base::Compare_xyz_3>
Compare_xyz_3;
typedef boost::false_type requires_test;
typedef boost::false_type requires_test; void set_radius(double radius) { _radius = radius; }
void set_radius(double radius){ _radius = radius;} Projection_sphere_traits_3(const Base_point& sphere=Base_point(0,0,0), double radius = 1);
Projection_sphere_traits_3(const Base_point& sphere=Base_point(0,0,0), double radius = 1); Orientation_2
orientation_2_object() const
{ return Orientation_2(_sphere, _radius); }
Orientation_1
orientation_1_object() const
{ return Orientation_1(_radius); }
Power_test_2
power_test_2_object() const
{ return Power_test_2(_sphere, _radius); }
Orientation_2 Coradial_sphere_2
orientation_2_object()const coradial_sphere_2_object() const
{return Orientation_2(_sphere, _radius);} { return Coradial_sphere_2(_sphere, _radius); }
Orientation_1 Inside_cone_2
orientation_1_object() const inside_cone_2_object() const
{return Orientation_1( _radius);} { return Inside_cone_2(_sphere, _radius); }
Power_test_2 Compute_squared_distance_2
power_test_2_object() const compute_squared_distance_3_object() const
{ return Power_test_2(_sphere, _radius);} { return Compute_squared_distance_2(_radius); }
Coradial_sphere_2 Compare_xyz_3
coradial_sphere_2_object() const compare_xyz_3_object() const
{return Coradial_sphere_2(_sphere, _radius);} { return Compare_xyz_3(_radius); }
Inside_cone_2 struct Construct_projected_point_3
inside_cone_2_object() const : public std::unary_function<Base_point,Point_2>
{return Inside_cone_2(_sphere, _radius);} {
const Base_point& sphere_center;
Compute_squared_distance_2 Point_2 operator()(const Base_point& pt) const { return Point_2(pt, sphere_center); }
compute_squared_distance_3_object() const
{ return Compute_squared_distance_2( _radius);}
Compare_xyz_3 Construct_projected_point_3(const Base_point& sc) : sphere_center(sc) { }
compare_xyz_3_object()const };
{return Compare_xyz_3(_radius);}
struct Construct_projected_point_3 Construct_projected_point_3
: public std::unary_function<Base_point,Point_2> construct_projected_point_3_object() const
{ { return Construct_projected_point_3(_sphere); }
const Base_point& sphere_center;
Point_2 operator()(const Base_point& pt) const
{ return Point_2(pt, sphere_center); }
Construct_projected_point_3(const Base_point& sc)
:sphere_center(sc) {}
};
Construct_projected_point_3
construct_projected_point_3_object() const {
return Construct_projected_point_3(_sphere);
};
protected : protected :
Base_point _sphere; Base_point _sphere;
}; };
template < class R > template < class R >
Projection_sphere_traits_3<R> :: Projection_sphere_traits_3<R> ::
Projection_sphere_traits_3(const Base_point& sphere, double radius) Projection_sphere_traits_3(const Base_point& sphere, double radius)
: _radius(radius), _sphere(sphere) : _radius(radius), _sphere(sphere)
{} { }
} //namespace CGAL
#endif
} // namespace CGAL
#endif // CGAL_PROJECTION_SPHERE_TRAITS_3_H

View File

@ -1,9 +1,10 @@
// Copyright (c) 1997 INRIA Sophia-Antipolis (France). // Copyright (c) 1997, 2012, 2019 INRIA Sophia-Antipolis (France).
// All rights reserved. // All rights reserved.
// //
// This file is part of CGAL (www.cgal.org); you may redistribute it under // This file is part of CGAL (www.cgal.org).
// the terms of the Q Public License version 1.0. // You can redistribute it and/or modify it under the terms of the GNU
// See the file LICENSE.QPL distributed with CGAL. // General Public License as published by the Free Software Foundation,
// either version 3 of the Licenxse, or (at your option) any later version.
// //
// Licensees holding a valid commercial license may use this file in // Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software. // accordance with the commercial license agreement provided with the software.
@ -11,17 +12,15 @@
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
// //
// $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.4-branch/Triangulation_2/include/CGAL/Triangulation_face_base_sphere_2.h $ // $URL$
// $Id: Triangulation_face_base_sphere_2.h 28567 2006-02-16 14:30:13Z lsaboret $ // $Id$
// // SPDX-License-Identifier: GPL-3.0+
// //
// Author(s) : Mariette Yvinec, Claudia Werner // Author(s) : Mariette Yvinec, Claudia Werner
#ifndef CGAL_TRIANGULATION_FACE_BASE_SPHERE_2_H #ifndef CGAL_TRIANGULATION_FACE_BASE_SPHERE_2_H
#define CGAL_TRIANGULATION_FACE_BASE_SPHERE_2_H #define CGAL_TRIANGULATION_FACE_BASE_SPHERE_2_H
#include <CGAL/basic.h>
#include <CGAL/triangulation_assertions.h>
#include <CGAL/Triangulation_ds_face_base_2.h> #include <CGAL/Triangulation_ds_face_base_2.h>
namespace CGAL { namespace CGAL {
@ -30,9 +29,6 @@ template < typename Gt, typename Fb = Triangulation_ds_face_base_2<> >
class Triangulation_face_base_sphere_2 class Triangulation_face_base_sphere_2
: public Fb : public Fb
{ {
protected:
bool _ghost;
public: public:
typedef Gt Geom_traits; typedef Gt Geom_traits;
typedef typename Fb::Vertex_handle Vertex_handle; typedef typename Fb::Vertex_handle Vertex_handle;
@ -41,76 +37,48 @@ public:
template < typename TDS2 > template < typename TDS2 >
struct Rebind_TDS { struct Rebind_TDS {
typedef typename Fb::template Rebind_TDS<TDS2>::Other Fb2; typedef typename Fb::template Rebind_TDS<TDS2>::Other Fb2;
typedef Triangulation_face_base_sphere_2<Gt, Fb2> Other; typedef Triangulation_face_base_sphere_2<Gt, Fb2> Other;
}; };
unsigned char _in_conflict_flag;
unsigned char _in_conflict_flag;
public: public:
void set_in_conflict_flag(unsigned char f) { _in_conflict_flag = f; } void set_in_conflict_flag(unsigned char f) { _in_conflict_flag = f; }
unsigned char get_in_conflict_flag() const { return _in_conflict_flag; } unsigned char get_in_conflict_flag() const { return _in_conflict_flag; }
public: public:
Triangulation_face_base_sphere_2() Triangulation_face_base_sphere_2()
: Fb(),_ghost(false) { : Fb(), _ghost(false)
set_in_conflict_flag(0); {
}
Triangulation_face_base_sphere_2(Vertex_handle v0,
Vertex_handle v1,
Vertex_handle v2)
: Fb(v0,v1,v2),_ghost(false) {
set_in_conflict_flag(0);
}
Triangulation_face_base_sphere_2(Vertex_handle v0,
Vertex_handle v1,
Vertex_handle v2,
Face_handle n0,
Face_handle n1,
Face_handle n2)
: Fb(v0,v1,v2,n0,n1,n2),_ghost(false) {
set_in_conflict_flag(0); set_in_conflict_flag(0);
} }
Triangulation_face_base_sphere_2(Vertex_handle v0,
Vertex_handle v1,
Vertex_handle v2)
: Fb(v0, v1, v2), _ghost(false)
{
set_in_conflict_flag(0);
}
Triangulation_face_base_sphere_2(Vertex_handle v0,
Vertex_handle v1,
Vertex_handle v2,
Face_handle n0,
Face_handle n1,
Face_handle n2)
: Fb(v0, v1, v2, n0, n1, n2), _ghost(false)
{
set_in_conflict_flag(0);
}
static int ccw(int i) {return Triangulation_cw_ccw_2::ccw(i);}
static int cw(int i) {return Triangulation_cw_ccw_2::cw(i);}
const bool& is_ghost() const { return _ghost; } const bool& is_ghost() const { return _ghost; }
bool& ghost() { return _ghost; } bool& ghost() { return _ghost; }
#ifndef CGAL_NO_DEPRECATED_CODE
Vertex_handle mirror_vertex(int i) const;
int mirror_index(int i) const;
#endif
protected:
bool _ghost;
}; };
#ifndef CGAL_NO_DEPRECATED_CODE } // namespace CGAL
template < class Gt, class Fb >
inline
typename Triangulation_face_base_sphere_2<Gt,Fb>::Vertex_handle
Triangulation_face_base_sphere_2<Gt,Fb>::
mirror_vertex(int i) const
{
CGAL_triangulation_precondition ( this->neighbor(i) != Face_handle()
&& this->dimension() >= 1);
//return neighbor(i)->vertex(neighbor(i)->index(this->handle()));
return this->neighbor(i)->vertex(mirror_index(i));
}
template < class Gt, class Fb >
inline int
Triangulation_face_base_sphere_2<Gt,Fb>::
mirror_index(int i) const
{
// return the index of opposite vertex in neighbor(i);
CGAL_triangulation_precondition (this->neighbor(i) != Face_handle() &&
this->dimension() >= 1);
if (this->dimension() == 1) {
return 1 - (this->neighbor(i)->index(this->vertex(1-i)));
}
return this->ccw( this->neighbor(i)->index(this->vertex(this->ccw(i))));
}
#endif
} //namespace CGAL
#endif //CGAL_Triangulation_face_base_sphere_2_H #endif //CGAL_Triangulation_face_base_sphere_2_H

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
// Copyright (c) 1997 INRIA Sophia-Antipolis (France). // Copyright (c) 1997, 2O12, 2019 INRIA Sophia-Antipolis (France).
// All rights reserved. // All rights reserved.
// //
// This file is part of CGAL (www.cgal.org). // This file is part of CGAL (www.cgal.org).
@ -14,7 +14,7 @@
// //
// $URL$ // $URL$
// $Id$ // $Id$
// // SPDX-License-Identifier: GPL-3.0+
// //
// Author(s) : Claudia Werner, Mariette Yvinec // Author(s) : Claudia Werner, Mariette Yvinec
@ -23,344 +23,346 @@
namespace CGAL{ namespace CGAL{
template <class Triangulation_> template <class Triangulation_>
class Triangulation_sphere_line_face_circulator_2 class Triangulation_sphere_line_face_circulator_2
:public Bidirectional_circulator_base<typename Triangulation_::Triangulation_data_structure::Face, : public Bidirectional_circulator_base<
std::size_t>, typename Triangulation_::Triangulation_data_structure::Face,
public Triangulation_cw_ccw_2 std::size_t>,
public Triangulation_cw_ccw_2
{ {
public: public:
typedef Triangulation_sphere_line_face_circulator_2<Triangulation_> Line_face_circulator; typedef Triangulation_sphere_line_face_circulator_2<Triangulation_> Line_face_circulator;
typedef Triangulation_ Triangulation; typedef Triangulation_ Triangulation;
typedef typename Triangulation::Geom_traits Gt; typedef typename Triangulation::Geom_traits Gt;
typedef typename Triangulation_::Triangulation_data_structure Tds; typedef typename Triangulation_::Triangulation_data_structure Tds;
typedef typename Tds::Vertex Vertex;
typedef typename Tds::Face Face;
typedef typename Tds::Edge Edge;
typedef typename Tds::Vertex_handle Vertex_handle;
typedef typename Tds::Face_handle Face_handle;
typedef typename Tds::Face_circulator Face_circulator;
typedef typename Gt::Point_2 Point; typedef typename Tds::Vertex Vertex;
typedef typename Triangulation::Locate_type Locate_type; typedef typename Tds::Face Face;
typedef typename Tds::Edge Edge;
typedef typename Tds::Vertex_handle Vertex_handle;
typedef typename Tds::Face_handle Face_handle;
typedef typename Tds::Face_circulator Face_circulator;
typedef typename Gt::Point_2 Point;
typedef typename Triangulation::Locate_type Locate_type;
enum State {undefined = -1, enum State {undefined = -1,
vertex_vertex, vertex_vertex,
vertex_edge, vertex_edge,
edge_vertex, edge_vertex,
edge_edge}; edge_edge};
private: private:
Face_handle pos; Face_handle pos;
const Triangulation* _tr; const Triangulation* _tr;
State s; State s;
int i; int i;
Point p, q; Point p, q;
public: public:
Triangulation_sphere_line_face_circulator_2() Triangulation_sphere_line_face_circulator_2()
: pos(), _tr(NULL), s(undefined), i(-1) : pos(), _tr(NULL), s(undefined), i(-1)
{} { }
Triangulation_sphere_line_face_circulator_2(Vertex_handle v, Triangulation_sphere_line_face_circulator_2(Vertex_handle v,
const Triangulation* tr, const Triangulation* tr,
const Point& dir); const Point& dir);
Line_face_circulator& operator++() ;
Line_face_circulator& operator--() ;
Line_face_circulator operator++(int);
Line_face_circulator operator--(int);
Face* operator->() { return &*pos; }
Face& operator*() { return *pos; }
Face_handle handle() { return pos; }
Line_face_circulator& operator++() ; operator const Face_handle() const { return pos; }
Line_face_circulator& operator--() ; bool operator==(const Line_face_circulator& lfc) const;
Line_face_circulator operator++(int); bool operator!=(const Line_face_circulator& lfc) const;
Line_face_circulator operator--(int);
Face* operator->() {return &*pos;}
Face& operator*() { return *pos;}
Face_handle handle() {return pos;}
operator const Face_handle() const {return pos;}
bool operator==(const Line_face_circulator& lfc) const;
bool operator!=(const Line_face_circulator& lfc) const;
bool operator==(const Face_handle& fh) const { return fh == pos; } bool operator==(const Face_handle& fh) const { return fh == pos; }
bool operator!=(const Face_handle& fh) const { return fh != pos; } bool operator!=(const Face_handle& fh) const { return fh != pos; }
bool operator==(Nullptr_t CGAL_triangulation_assertion_code(n)) const; bool operator==(Nullptr_t CGAL_triangulation_assertion_code(n)) const;
bool operator!=(Nullptr_t n) const; bool operator!=(Nullptr_t n) const;
bool is_empty() const; bool is_empty() const;
bool locate(const Point& t, Locate_type &lt, int &li); bool locate(const Point& t, Locate_type &lt, int &li);
//private: //private:
Triangulation_sphere_line_face_circulator_2(const Face_handle& face, Triangulation_sphere_line_face_circulator_2(const Face_handle& face,
int index, int index,
State state, State state,
const Triangulation * t, const Triangulation * t,
const Point& pp, const Point& pp,
const Point& qq); const Point& qq);
private: private:
void increment(); void increment();
void decrement(); void decrement();
}; };
template < class Triangulation > template < class Triangulation >
inline inline
bool bool
operator==(typename Triangulation::Triangulation_data_structure::Face_handle fh, operator==(typename Triangulation::Triangulation_data_structure::Face_handle fh,
Triangulation_sphere_line_face_circulator_2<Triangulation> fc) Triangulation_sphere_line_face_circulator_2<Triangulation> fc)
{ {
return (fc==fh); return (fc == fh);
} }
template < class Triangulation > template < class Triangulation >
inline inline
bool bool
operator!=(typename Triangulation::Triangulation_data_structure::Face_handle fh, operator!=(typename Triangulation::Triangulation_data_structure::Face_handle fh,
Triangulation_sphere_line_face_circulator_2<Triangulation> fc) Triangulation_sphere_line_face_circulator_2<Triangulation> fc)
{ {
return (fc!=fh); return (fc != fh);
} }
template < class Triangulation >
Triangulation_sphere_line_face_circulator_2<Triangulation>::
Triangulation_sphere_line_face_circulator_2(Vertex_handle v,
const Triangulation* tr,
const Point& dir)
:pos(), _tr(tr), s(undefined)
// begin at the face incident to v, traversed by the ray from v to dir
// or null iterator
{
CGAL_triangulation_precondition((_tr->dimension() == 2) &&
(! _tr->xy_equal(v->point(), dir)));
p = v->point();
q = dir;
// find a vertex to the left of pq
// if there is no, the line_face_circulator is null
Face_circulator fc = _tr->incident_faces(v);
Face_circulator done(fc);
int ic = fc->index(v);
Vertex_handle vt = fc->vertex(cw(ic));
//Orientation o = _tr->orientation(p, q, vt->point());
while( _tr->orientation(p, q, vt->point()) != LEFT_TURN)
{
++fc;
ic = fc->index(v);
vt= fc->vertex(cw(ic));
template < class Triangulation > if(fc == done)
Triangulation_sphere_line_face_circulator_2<Triangulation>:: {
Triangulation_sphere_line_face_circulator_2(Vertex_handle v, *this = Line_face_circulator();
const Triangulation* tr, return;
const Point& dir) }
:pos(), _tr(tr), s(undefined) }
// begin at the face incident to v, traversed by the ray from v to dir
// or null iterator
{
CGAL_triangulation_precondition((_tr->dimension() == 2) &&
(! _tr->xy_equal(v->point(),dir)));
p=v->point();
q=dir;
// find a vertex to the left of pq Vertex_handle vr = fc-> vertex(ccw(ic));
// if there is no, the line_face_circulator is null Orientation pqr = RIGHT_TURN; // warning "pqr might be used uninitialized"
Face_circulator fc = _tr->incident_faces(v); while((pqr = _tr->orientation(p, q, vr->point())) == LEFT_TURN)
Face_circulator done(fc); {
int ic = fc->index(v); --fc;
Vertex_handle vt= fc->vertex(cw(ic)); ic = fc->index(v);
//Orientation o = _tr->orientation(p, q, vt->point()); vr = fc-> vertex(ccw(ic));
while( _tr->orientation(p, q, vt->point()) != LEFT_TURN) { }
++fc;
ic = fc->index(v);
vt= fc->vertex(cw(ic));
if (fc == done) { *this = Line_face_circulator(); return;}
}
Vertex_handle vr = fc-> vertex(ccw(ic)); // first intersected face found
Orientation pqr = RIGHT_TURN; // warning "pqr might be used uninitialized" // [pqr] is COLLINEAR or RIGHT_TURN
while ( (pqr = _tr->orientation(p, q, vr->point()))== LEFT_TURN ) { ic = fc->index(v);
--fc; vt= fc->vertex(cw(ic));
ic = fc->index(v); CGAL_triangulation_assertion (_tr->orientation(p, q, vt->point()) == LEFT_TURN);
vr = fc-> vertex(ccw(ic));
}
if(pqr == COLLINEAR)
{
pos = fc;
s = vertex_vertex;
i = ccw(ic);
}
else // pqr == RIGHT_TURN
{
pos = fc;
s = vertex_edge;
i = ic ;
}
}
template < class Triangulation >
inline
void
Triangulation_sphere_line_face_circulator_2<Triangulation>::
increment()
{
CGAL_triangulation_precondition(pos != Face_handle());
if(s == vertex_vertex || s == edge_vertex)
{
Orientation o;
do
{
Face_handle n = pos->neighbor(cw(i));
i = n->index(pos);
pos = n;
// first intersected face found o = _tr->orientation(p, q, pos->vertex(i)->point());
// [pqr] is COLLINEAR or RIGHT_TURN i = cw(i);
ic = fc->index(v); } while(o == LEFT_TURN);
vt= fc->vertex(cw(ic));
CGAL_triangulation_assertion (_tr->orientation(p,q, vt->point())==
LEFT_TURN );
if (pqr == COLLINEAR) { if(o == COLLINEAR)
pos = fc; {
s = vertex_vertex; s = vertex_vertex;
i = ccw(ic); i = ccw(i);
} }
else { // pqr==RIGHT_TURN else
pos = fc; {
s = vertex_edge; s = vertex_edge;
i = ic ; }
} }
return; else
} {
Face_handle n = pos->neighbor(i);
int ni = n->index(pos);
pos = n ;
Orientation o = _tr->orientation(p, q, pos->vertex(ni)->point());
switch(o)
{
case LEFT_TURN:
s = edge_edge;
i = ccw(ni);
break;
case RIGHT_TURN:
s = edge_edge;
i = cw(ni);
break;
default:
s = edge_vertex;
i = ni;
}
}
}
template < class Triangulation >
void
Triangulation_sphere_line_face_circulator_2<Triangulation>::
decrement()
{
CGAL_triangulation_precondition(pos != Face_handle());
if(s == vertex_vertex || s == vertex_edge)
{
if(s == vertex_vertex)
i = cw(i);
Orientation o;
do
{
Face_handle n = pos->neighbor(ccw(i));
i = n->index(pos);
pos = n;
o = _tr->orientation(p, q, pos->vertex(i)->point());
i = ccw(i);
}
while(o == LEFT_TURN);
template < class Triangulation > s = (o == COLLINEAR) ? vertex_vertex : edge_vertex;
inline
void
Triangulation_sphere_line_face_circulator_2<Triangulation>::
increment()
{
CGAL_triangulation_precondition(pos != Face_handle());
if(s == vertex_vertex || s == edge_vertex) {
Orientation o;
do{
Face_handle n = pos->neighbor(cw(i));
i = n->index(pos);
pos = n;
o = _tr->orientation(p, q, pos->vertex(i)->point()); }
i = cw(i); else // s == edge_edge || s == edge_vertex
}while(o == LEFT_TURN); {
// the following is not nice. A better solution is to say
// that index i is at the vertex that is alone on one side of l(p, q)
if(s == edge_edge)
i = (_tr->orientation(p, q, pos->vertex(i)->point()) == LEFT_TURN) ? cw(i) : ccw(i);
if(o == COLLINEAR) { Face_handle n = pos->neighbor(i);
s = vertex_vertex; i = n->index(pos);
i = ccw(i); pos = n;
} Orientation o = _tr->orientation(p, q, pos->vertex(i)->point());
else {
s = vertex_edge;
}
}
else {
Face_handle n = pos->neighbor(i);
int ni = n->index(pos);
pos = n ;
Orientation o = _tr->orientation(p,q,pos->vertex(ni)->point());
switch(o){ s = (o == COLLINEAR) ? vertex_edge : edge_edge;
case LEFT_TURN: }
s = edge_edge; }
i = ccw(ni);
break;
case RIGHT_TURN:
s = edge_edge;
i = cw(ni);
break;
default:
s = edge_vertex;
i = ni;
}
}
}
template < class Triangulation > template < class Triangulation >
void inline
Triangulation_sphere_line_face_circulator_2<Triangulation>:: Triangulation_sphere_line_face_circulator_2<Triangulation>&
decrement() Triangulation_sphere_line_face_circulator_2<Triangulation>::
{ operator++()
CGAL_triangulation_precondition(pos != Face_handle()); {
if(s == vertex_vertex || s == vertex_edge) { CGAL_triangulation_precondition(pos != Face_handle()) ;
if(s == vertex_vertex){ increment();
i = cw(i); return *this;
} }
Orientation o;
do{
Face_handle n = pos->neighbor(ccw(i));
i = n->index(pos);
pos = n;
o = _tr->orientation(p, q, pos->vertex(i)->point()); template < class Triangulation >
i = ccw(i); inline
}while(o == LEFT_TURN); Triangulation_sphere_line_face_circulator_2<Triangulation>&
Triangulation_sphere_line_face_circulator_2<Triangulation>::
operator--()
{
CGAL_triangulation_precondition(pos != Face_handle()) ;
decrement();
return *this;
}
s = (o == COLLINEAR) ? vertex_vertex : edge_vertex; template < class Triangulation >
inline
Triangulation_sphere_line_face_circulator_2<Triangulation>
Triangulation_sphere_line_face_circulator_2<Triangulation>::
operator++(int)
{
Line_face_circulator tmp(*this);
++(*this);
return tmp;
}
} template < class Triangulation >
else { // s == edge_edge || s == edge_vertex inline
// the following is not nice. A better solution is to say Triangulation_sphere_line_face_circulator_2<Triangulation>
// that index i is at the vertex that is alone on one side of l(p,q) Triangulation_sphere_line_face_circulator_2<Triangulation>::
if(s == edge_edge){ operator--(int)
i = (_tr->orientation {
(p, q, Line_face_circulator tmp(*this);
pos->vertex(i)->point()) == --(*this);
LEFT_TURN) return tmp;
? cw(i) : ccw(i); }
}
Face_handle n = pos->neighbor(i);
i = n->index(pos);
pos = n;
Orientation o = _tr->orientation(p, q, pos->vertex(i)->point());
s = (o == COLLINEAR) ? vertex_edge : edge_edge; template < class Triangulation >
} inline bool
} Triangulation_sphere_line_face_circulator_2<Triangulation>::
operator==(const Line_face_circulator& lfc) const
{
CGAL_triangulation_precondition(pos != Face_handle() && lfc.pos != Face_handle());
return (pos == lfc.pos && _tr == lfc._tr &&
s == lfc.s && p==lfc.p && q==lfc.q);
}
template < class Triangulation >
inline bool
Triangulation_sphere_line_face_circulator_2<Triangulation>::
operator!=(const Line_face_circulator& lfc) const
{
return !(*this == lfc);
}
template < class Triangulation >
inline bool
Triangulation_sphere_line_face_circulator_2<Triangulation>::
is_empty() const
{
return pos == Face_handle();
}
template < class Triangulation > template < class Triangulation >
inline inline bool
Triangulation_sphere_line_face_circulator_2<Triangulation>& Triangulation_sphere_line_face_circulator_2<Triangulation>::
Triangulation_sphere_line_face_circulator_2<Triangulation>:: operator==(Nullptr_t CGAL_triangulation_assertion_code(n)) const
operator++() {
{ CGAL_triangulation_assertion(n == NULL);
CGAL_triangulation_precondition( pos != Face_handle()) ; return pos == Face_handle();
increment(); }
return *this;
}
template < class Triangulation > template < class Triangulation >
inline inline bool
Triangulation_sphere_line_face_circulator_2<Triangulation>& Triangulation_sphere_line_face_circulator_2<Triangulation>::
Triangulation_sphere_line_face_circulator_2<Triangulation>:: operator!=(Nullptr_t n) const
operator--() {
{ CGAL_triangulation_assertion(n == NULL);
CGAL_triangulation_precondition(pos != Face_handle()) ; return !(*this == n);
decrement(); }
return *this;
}
template < class Triangulation > } // end namespace CGAL
inline
Triangulation_sphere_line_face_circulator_2<Triangulation>
Triangulation_sphere_line_face_circulator_2<Triangulation>::
operator++(int)
{
Line_face_circulator tmp(*this);
++(*this);
return tmp;
}
template < class Triangulation >
inline
Triangulation_sphere_line_face_circulator_2<Triangulation>
Triangulation_sphere_line_face_circulator_2<Triangulation>::
operator--(int)
{
Line_face_circulator tmp(*this);
--(*this);
return tmp;
}
template < class Triangulation >
inline bool
Triangulation_sphere_line_face_circulator_2<Triangulation>::
operator==(const Line_face_circulator& lfc) const
{
CGAL_triangulation_precondition( pos != Face_handle() &&
lfc.pos != Face_handle());
return ( pos == lfc.pos && _tr == lfc._tr &&
s== lfc.s && p==lfc.p && q==lfc.q);
}
template < class Triangulation >
inline bool
Triangulation_sphere_line_face_circulator_2<Triangulation>::
operator!=(const Line_face_circulator& lfc) const
{
return !(*this == lfc);
}
template < class Triangulation >
inline bool
Triangulation_sphere_line_face_circulator_2<Triangulation>::
is_empty() const
{
return pos == Face_handle();
}
template < class Triangulation >
inline bool
Triangulation_sphere_line_face_circulator_2<Triangulation>::
operator==(Nullptr_t CGAL_triangulation_assertion_code(n)) const
{
CGAL_triangulation_assertion( n == NULL);
return pos == Face_handle();
}
template < class Triangulation >
inline bool
Triangulation_sphere_line_face_circulator_2<Triangulation>::
operator!=(Nullptr_t n) const
{
CGAL_triangulation_assertion( n == NULL);
return !(*this == n);
}
}//namespace
#endif #endif