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_traits_2<K> Traits;
typedef CGAL::Delaunay_triangulation_sphere_2<Traits> DToS2; 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.begin(), cst),
boost::make_transform_iterator(points.end(), 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::Vertex_handle Vertex_handle;
typedef typename TDS::Face_handle Face_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 typename Fb::template Rebind_TDS<TDS2>::Other Fb2;
typedef Constrained_triangulation_face_base_sphere_2<Gt,Fb2> Other; typedef Constrained_triangulation_face_base_sphere_2<Gt, Fb2> Other;
}; };
protected: protected:
bool C[3]; bool C[3];
@ -53,15 +55,15 @@ 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,
@ -70,12 +72,11 @@ public:
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,
@ -84,44 +85,42 @@ public:
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,11 +49,8 @@ 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);
}
}; };
/* /*
@ -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(); }

View File

@ -1,80 +1,82 @@
// 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); } {
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 Point_2& r) const const Point_2& r) const
{ {
return -coplanar_orientation(p,q,_sphere,r); return -coplanar_orientation(p, q,_sphere, r);
} }
Oriented_side operator()(const Point_2& p,
Oriented_side operator() (const Point_2& p,
const Point_2& q) const const Point_2& q) const
{ {
Comparison_result pq=compare_xyz(p,q); Comparison_result pq = compare_xyz(p, q);
if(pq==EQUAL){ 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: public:
typedef Oriented_side result_type; typedef Oriented_side result_type;
protected: protected:
Point_2 _sphere; 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
@ -82,33 +84,34 @@ 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
@ -123,89 +126,86 @@ public:
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, Comparison_result operator()(const Point_2& p, const Point_2& q,
const Point_2& r, const Point_2 & s) const const Point_2& r, const Point_2& s) const
{return orientation(p,q,r,s);} { 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;
Coradial_sphere_2(const Point_2& sphere);
bool operator()(const Point_2& p, const Point_2 q) const bool operator()(const Point_2& p, const Point_2 q) const
{ {
return collinear(_sphere,p,q) && return collinear(_sphere, p, q) &&
( are_ordered_along_line(_sphere,p,q) || are_ordered_along_line(_sphere,q,p) ); (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) ||
collinear(_sphere, q, r) ||
orientation(_sphere, p, q, r) != COLLINEAR)
return false; return false;
if( collinear(_sphere,p,q) )
if(collinear(_sphere, p, q))
return true; return true;
return coplanar_orientation(_sphere,p,q,r) == ( POSITIVE==coplanar_orientation(_sphere,q,p,r) );
} 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;
@ -225,84 +225,67 @@ public:
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;
typedef boost::true_type requires_test;
double _radius; double _radius;
void set_radius(double a) { _radius = a; }
typedef boost::true_type requires_test; Delaunay_triangulation_sphere_traits_2(const Point_2& sphere = Point_2(0,0,0));
void set_radius(double a){_radius = a;}
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_3
construct_segment_2_object()const construct_segment_2_object() const
{return Construct_segment_3();} { return Construct_segment_3(); }
Compute_squared_distance_2
Compute_squared_distance_2 compute_squared_distance_3_object() const compute_squared_distance_3_object() const
{ return Compute_squared_distance_2(); } { 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,133 +1,153 @@
// 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(const Base_point &p, const typename K::Point_3& sphere_center)
:Base_point(p){compute_scale( p-(sphere_center-ORIGIN) );}
Projected_point() : Base_point() { }
Projected_point(const Base_point& p,
const typename K::Point_3& sphere_center)
: Base_point(p)
{
compute_scale(p-(sphere_center-ORIGIN));
}
public: public:
double _scale; double _scale;
void scale(){return _scale;} void scale() { return _scale; }
private: private:
void compute_scale(double x, double y, double z){ void compute_scale(double x, double y, double z)
{
double tmp = x*x+y*y+z*z; double tmp = x*x+y*y+z*z;
if (tmp == 0 ) if(tmp == 0)
_scale = 0; _scale = 0;
else else
_scale = 1/sqrt(tmp); _scale = 1 / sqrt(tmp);
} }
void compute_scale(const Base_point &p){ void compute_scale(const Base_point& p)
{
return compute_scale(p.x(), p.y(), p.z()); 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
// 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 // adaptor for calling the Predicate_ with the points projected on the sphere
template < class K, class P, class Predicate_ > template < class K, class P, class Predicate_ >
class Traits_with_projection_adaptor { class Traits_with_projection_adaptor
{
public: public:
typedef Predicate_ Predicate; typedef Predicate_ Predicate;
typedef typename P::Point_2 Point; typedef typename P::Point_2 Point;
typedef typename K::Point_2 Base_point; typedef typename K::Point_2 Base_point;
Traits_with_projection_adaptor(Base_point sphere, double radius):_radius(radius), _sphere(sphere){}
Traits_with_projection_adaptor(Base_point sphere, double radius) : _radius(radius), _sphere(sphere) { }
double _radius; double _radius;
Base_point _sphere ; Base_point _sphere ;
typedef typename Predicate::result_type result_type; 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(_sphere)(project(p0), project(p1));} { return Predicate(_sphere)(project(p0), project(p1)); }
result_type operator()(const Point& p0, const Point& p1, const Point& p2) result_type operator()(const Point& p0, const Point& p1, const Point& p2)
{return Predicate(_sphere)(project(p0), project(p1), project(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) 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));} { 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) 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));} { return Predicate(_sphere)(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; {
double scale = _radius * p._scale;
return Base_point(scale*p.x(), scale*p.y(), scale*p.z()); 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){}
Traits_with_projection_adaptorKernel(double radius) : _radius(radius) { }
double _radius; double _radius;
Base_point _sphere ; Base_point _sphere;
typedef typename Predicate::result_type result_type; 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) result_type operator()(const Point& p0, const Point& p1, const Point& p2)
{return Predicate()(project(p0), project(p1), project(p2));} { return Predicate()(project(p0), project(p1), project(p2)); }
result_type operator ()(const Point& p0, const Point& p1, const Point& p2, const Point& 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));} { 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) 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));} { 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; {
double scale = _radius * p._scale;
return Base_point(scale*p.x(), scale*p.y(), scale*p.z()); 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:
@ -140,92 +160,72 @@ public:
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); }
Orientation_2 Power_test_2
orientation_2_object()const power_test_2_object() const
{return Orientation_2(_sphere, _radius);} { return Power_test_2(_sphere, _radius); }
Orientation_1 Coradial_sphere_2
orientation_1_object() const coradial_sphere_2_object() const
{return Orientation_1( _radius);} { return Coradial_sphere_2(_sphere, _radius); }
Power_test_2 Inside_cone_2
power_test_2_object() const inside_cone_2_object() const
{ return Power_test_2(_sphere, _radius);} { return Inside_cone_2(_sphere, _radius); }
Coradial_sphere_2 Compute_squared_distance_2
coradial_sphere_2_object() const compute_squared_distance_3_object() const
{return Coradial_sphere_2(_sphere, _radius);} { return Compute_squared_distance_2(_radius); }
Inside_cone_2 Compare_xyz_3
inside_cone_2_object() const compare_xyz_3_object() const
{return Inside_cone_2(_sphere, _radius);} { return Compare_xyz_3(_radius); }
Compute_squared_distance_2 struct Construct_projected_point_3
compute_squared_distance_3_object() const
{ return Compute_squared_distance_2( _radius);}
Compare_xyz_3
compare_xyz_3_object()const
{return Compare_xyz_3(_radius);}
struct Construct_projected_point_3
: public std::unary_function<Base_point,Point_2> : public std::unary_function<Base_point,Point_2>
{ {
const Base_point& sphere_center; const Base_point& sphere_center;
Point_2 operator()(const Base_point& pt) const Point_2 operator()(const Base_point& pt) const { return Point_2(pt, sphere_center); }
{ return Point_2(pt, sphere_center); }
Construct_projected_point_3(const Base_point& sc) Construct_projected_point_3(const Base_point& sc) : sphere_center(sc) { }
:sphere_center(sc) {} };
};
Construct_projected_point_3 Construct_projected_point_3
construct_projected_point_3_object() const { construct_projected_point_3_object() const
return Construct_projected_point_3(_sphere); { 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;
@ -43,23 +39,27 @@ public:
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); set_in_conflict_flag(0);
} }
Triangulation_face_base_sphere_2(Vertex_handle v0, Triangulation_face_base_sphere_2(Vertex_handle v0,
Vertex_handle v1, Vertex_handle v1,
Vertex_handle v2) Vertex_handle v2)
: Fb(v0,v1,v2),_ghost(false) { : Fb(v0, v1, v2), _ghost(false)
{
set_in_conflict_flag(0); set_in_conflict_flag(0);
} }
Triangulation_face_base_sphere_2(Vertex_handle v0, Triangulation_face_base_sphere_2(Vertex_handle v0,
Vertex_handle v1, Vertex_handle v1,
@ -67,50 +67,18 @@ public:
Face_handle n0, Face_handle n0,
Face_handle n1, Face_handle n1,
Face_handle n2) Face_handle n2)
: Fb(v0,v1,v2,n0,n1,n2),_ghost(false) { : Fb(v0, v1, v2, n0, n1, n2), _ghost(false)
{
set_in_conflict_flag(0); 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 protected:
Vertex_handle mirror_vertex(int i) const; bool _ghost;
int mirror_index(int i) const;
#endif
}; };
#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,7 +23,8 @@
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<
typename Triangulation_::Triangulation_data_structure::Face,
std::size_t>, std::size_t>,
public Triangulation_cw_ccw_2 public Triangulation_cw_ccw_2
{ {
@ -32,6 +33,7 @@ public:
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::Vertex Vertex;
typedef typename Tds::Face Face; typedef typename Tds::Face Face;
typedef typename Tds::Edge Edge; typedef typename Tds::Edge Edge;
@ -42,7 +44,6 @@ public:
typedef typename Gt::Point_2 Point; typedef typename Gt::Point_2 Point;
typedef typename Triangulation::Locate_type Locate_type; typedef typename Triangulation::Locate_type Locate_type;
enum State {undefined = -1, enum State {undefined = -1,
vertex_vertex, vertex_vertex,
vertex_edge, vertex_edge,
@ -59,21 +60,21 @@ private:
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--() ; Line_face_circulator& operator--() ;
Line_face_circulator operator++(int); Line_face_circulator operator++(int);
Line_face_circulator operator--(int); Line_face_circulator operator--(int);
Face* operator->() {return &*pos;} Face* operator->() { return &*pos; }
Face& operator*() { return *pos;} Face& operator*() { return *pos; }
Face_handle handle() {return pos;} Face_handle handle() { return pos; }
operator const Face_handle() const {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 Line_face_circulator& lfc) const; bool operator!=(const Line_face_circulator& lfc) const;
@ -97,121 +98,126 @@ private:
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>::
template < class Triangulation > Triangulation_sphere_line_face_circulator_2(Vertex_handle v,
Triangulation_sphere_line_face_circulator_2<Triangulation>::
Triangulation_sphere_line_face_circulator_2(Vertex_handle v,
const Triangulation* tr, const Triangulation* tr,
const Point& dir) const Point& dir)
:pos(), _tr(tr), s(undefined) :pos(), _tr(tr), s(undefined)
// begin at the face incident to v, traversed by the ray from v to dir // begin at the face incident to v, traversed by the ray from v to dir
// or null iterator // or null iterator
{ {
CGAL_triangulation_precondition((_tr->dimension() == 2) && CGAL_triangulation_precondition((_tr->dimension() == 2) &&
(! _tr->xy_equal(v->point(),dir))); (! _tr->xy_equal(v->point(), dir)));
p=v->point(); p = v->point();
q=dir; q = dir;
// find a vertex to the left of pq // find a vertex to the left of pq
// if there is no, the line_face_circulator is null // if there is no, the line_face_circulator is null
Face_circulator fc = _tr->incident_faces(v); Face_circulator fc = _tr->incident_faces(v);
Face_circulator done(fc); Face_circulator done(fc);
int ic = fc->index(v); int ic = fc->index(v);
Vertex_handle vt= fc->vertex(cw(ic)); Vertex_handle vt = fc->vertex(cw(ic));
//Orientation o = _tr->orientation(p, q, vt->point()); //Orientation o = _tr->orientation(p, q, vt->point());
while( _tr->orientation(p, q, vt->point()) != LEFT_TURN) { while( _tr->orientation(p, q, vt->point()) != LEFT_TURN)
{
++fc; ++fc;
ic = fc->index(v); ic = fc->index(v);
vt= fc->vertex(cw(ic)); vt= fc->vertex(cw(ic));
if (fc == done) { *this = Line_face_circulator(); return;}
if(fc == done)
{
*this = Line_face_circulator();
return;
}
} }
Vertex_handle vr = fc-> vertex(ccw(ic)); Vertex_handle vr = fc-> vertex(ccw(ic));
Orientation pqr = RIGHT_TURN; // warning "pqr might be used uninitialized" Orientation pqr = RIGHT_TURN; // warning "pqr might be used uninitialized"
while ( (pqr = _tr->orientation(p, q, vr->point()))== LEFT_TURN ) { while((pqr = _tr->orientation(p, q, vr->point())) == LEFT_TURN)
{
--fc; --fc;
ic = fc->index(v); ic = fc->index(v);
vr = fc-> vertex(ccw(ic)); vr = fc-> vertex(ccw(ic));
} }
// first intersected face found // first intersected face found
// [pqr] is COLLINEAR or RIGHT_TURN // [pqr] is COLLINEAR or RIGHT_TURN
ic = fc->index(v); ic = fc->index(v);
vt= fc->vertex(cw(ic)); vt= fc->vertex(cw(ic));
CGAL_triangulation_assertion (_tr->orientation(p,q, vt->point())== CGAL_triangulation_assertion (_tr->orientation(p, q, vt->point()) == LEFT_TURN);
LEFT_TURN );
if (pqr == COLLINEAR) { if(pqr == COLLINEAR)
{
pos = fc; pos = fc;
s = vertex_vertex; s = vertex_vertex;
i = ccw(ic); i = ccw(ic);
} }
else { // pqr==RIGHT_TURN else // pqr == RIGHT_TURN
{
pos = fc; pos = fc;
s = vertex_edge; s = vertex_edge;
i = ic ; i = ic ;
} }
return; }
}
template < class Triangulation >
inline
void
Triangulation_sphere_line_face_circulator_2<Triangulation>::
template < class Triangulation > increment()
inline {
void
Triangulation_sphere_line_face_circulator_2<Triangulation>::
increment()
{
CGAL_triangulation_precondition(pos != Face_handle()); CGAL_triangulation_precondition(pos != Face_handle());
if(s == vertex_vertex || s == edge_vertex) { if(s == vertex_vertex || s == edge_vertex)
{
Orientation o; Orientation o;
do{ do
{
Face_handle n = pos->neighbor(cw(i)); Face_handle n = pos->neighbor(cw(i));
i = n->index(pos); i = n->index(pos);
pos = n; pos = n;
o = _tr->orientation(p, q, pos->vertex(i)->point()); o = _tr->orientation(p, q, pos->vertex(i)->point());
i = cw(i); i = cw(i);
}while(o == LEFT_TURN); } while(o == LEFT_TURN);
if(o == COLLINEAR) { if(o == COLLINEAR)
{
s = vertex_vertex; s = vertex_vertex;
i = ccw(i); i = ccw(i);
} }
else { else
{
s = vertex_edge; s = vertex_edge;
} }
} }
else { else
{
Face_handle n = pos->neighbor(i); Face_handle n = pos->neighbor(i);
int ni = n->index(pos); int ni = n->index(pos);
pos = n ; pos = n ;
Orientation o = _tr->orientation(p,q,pos->vertex(ni)->point()); Orientation o = _tr->orientation(p, q, pos->vertex(ni)->point());
switch(o){ switch(o)
{
case LEFT_TURN: case LEFT_TURN:
s = edge_edge; s = edge_edge;
i = ccw(ni); i = ccw(ni);
@ -225,41 +231,41 @@ private:
i = ni; i = ni;
} }
} }
} }
template < class Triangulation > template < class Triangulation >
void void
Triangulation_sphere_line_face_circulator_2<Triangulation>:: Triangulation_sphere_line_face_circulator_2<Triangulation>::
decrement() decrement()
{ {
CGAL_triangulation_precondition(pos != Face_handle()); CGAL_triangulation_precondition(pos != Face_handle());
if(s == vertex_vertex || s == vertex_edge) { if(s == vertex_vertex || s == vertex_edge)
if(s == vertex_vertex){ {
if(s == vertex_vertex)
i = cw(i); i = cw(i);
}
Orientation o; Orientation o;
do{ do
{
Face_handle n = pos->neighbor(ccw(i)); Face_handle n = pos->neighbor(ccw(i));
i = n->index(pos); i = n->index(pos);
pos = n; pos = n;
o = _tr->orientation(p, q, pos->vertex(i)->point()); o = _tr->orientation(p, q, pos->vertex(i)->point());
i = ccw(i); i = ccw(i);
}while(o == LEFT_TURN); }
while(o == LEFT_TURN);
s = (o == COLLINEAR) ? vertex_vertex : edge_vertex; s = (o == COLLINEAR) ? vertex_vertex : edge_vertex;
} }
else { // s == edge_edge || s == edge_vertex else // s == edge_edge || s == edge_vertex
{
// the following is not nice. A better solution is to say // 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) // that index i is at the vertex that is alone on one side of l(p, q)
if(s == edge_edge){ if(s == edge_edge)
i = (_tr->orientation i = (_tr->orientation(p, q, pos->vertex(i)->point()) == LEFT_TURN) ? cw(i) : ccw(i);
(p, q,
pos->vertex(i)->point()) ==
LEFT_TURN)
? cw(i) : ccw(i);
}
Face_handle n = pos->neighbor(i); Face_handle n = pos->neighbor(i);
i = n->index(pos); i = n->index(pos);
pos = n; pos = n;
@ -267,100 +273,96 @@ private:
s = (o == COLLINEAR) ? vertex_edge : edge_edge; s = (o == COLLINEAR) ? vertex_edge : edge_edge;
} }
} }
template < class Triangulation >
inline
template < class Triangulation > Triangulation_sphere_line_face_circulator_2<Triangulation>&
inline Triangulation_sphere_line_face_circulator_2<Triangulation>::
Triangulation_sphere_line_face_circulator_2<Triangulation>& operator++()
Triangulation_sphere_line_face_circulator_2<Triangulation>:: {
operator++() CGAL_triangulation_precondition(pos != Face_handle()) ;
{
CGAL_triangulation_precondition( pos != Face_handle()) ;
increment(); increment();
return *this; return *this;
} }
template < class Triangulation > template < class Triangulation >
inline inline
Triangulation_sphere_line_face_circulator_2<Triangulation>& Triangulation_sphere_line_face_circulator_2<Triangulation>&
Triangulation_sphere_line_face_circulator_2<Triangulation>:: Triangulation_sphere_line_face_circulator_2<Triangulation>::
operator--() operator--()
{ {
CGAL_triangulation_precondition(pos != Face_handle()) ; CGAL_triangulation_precondition(pos != Face_handle()) ;
decrement(); decrement();
return *this; return *this;
} }
template < class Triangulation > template < class Triangulation >
inline inline
Triangulation_sphere_line_face_circulator_2<Triangulation> Triangulation_sphere_line_face_circulator_2<Triangulation>
Triangulation_sphere_line_face_circulator_2<Triangulation>:: Triangulation_sphere_line_face_circulator_2<Triangulation>::
operator++(int) operator++(int)
{ {
Line_face_circulator tmp(*this); Line_face_circulator tmp(*this);
++(*this); ++(*this);
return tmp; return tmp;
} }
template < class Triangulation > template < class Triangulation >
inline inline
Triangulation_sphere_line_face_circulator_2<Triangulation> Triangulation_sphere_line_face_circulator_2<Triangulation>
Triangulation_sphere_line_face_circulator_2<Triangulation>:: Triangulation_sphere_line_face_circulator_2<Triangulation>::
operator--(int) operator--(int)
{ {
Line_face_circulator tmp(*this); Line_face_circulator tmp(*this);
--(*this); --(*this);
return tmp; return tmp;
} }
template < class Triangulation > template < class Triangulation >
inline bool inline bool
Triangulation_sphere_line_face_circulator_2<Triangulation>:: Triangulation_sphere_line_face_circulator_2<Triangulation>::
operator==(const Line_face_circulator& lfc) const operator==(const Line_face_circulator& lfc) const
{ {
CGAL_triangulation_precondition( pos != Face_handle() && CGAL_triangulation_precondition(pos != Face_handle() && lfc.pos != Face_handle());
lfc.pos != Face_handle()); return (pos == lfc.pos && _tr == lfc._tr &&
return ( pos == lfc.pos && _tr == lfc._tr && s == lfc.s && p==lfc.p && q==lfc.q);
s== lfc.s && p==lfc.p && q==lfc.q); }
}
template < class Triangulation > template < class Triangulation >
inline bool inline bool
Triangulation_sphere_line_face_circulator_2<Triangulation>:: Triangulation_sphere_line_face_circulator_2<Triangulation>::
operator!=(const Line_face_circulator& lfc) const operator!=(const Line_face_circulator& lfc) const
{ {
return !(*this == lfc); return !(*this == lfc);
} }
template < class Triangulation > template < class Triangulation >
inline bool inline bool
Triangulation_sphere_line_face_circulator_2<Triangulation>:: Triangulation_sphere_line_face_circulator_2<Triangulation>::
is_empty() const is_empty() const
{ {
return pos == Face_handle(); return pos == Face_handle();
} }
template < class Triangulation > template < class Triangulation >
inline bool inline bool
Triangulation_sphere_line_face_circulator_2<Triangulation>:: Triangulation_sphere_line_face_circulator_2<Triangulation>::
operator==(Nullptr_t CGAL_triangulation_assertion_code(n)) const operator==(Nullptr_t CGAL_triangulation_assertion_code(n)) const
{ {
CGAL_triangulation_assertion( n == NULL); CGAL_triangulation_assertion(n == NULL);
return pos == Face_handle(); return pos == Face_handle();
} }
template < class Triangulation > template < class Triangulation >
inline bool inline bool
Triangulation_sphere_line_face_circulator_2<Triangulation>:: Triangulation_sphere_line_face_circulator_2<Triangulation>::
operator!=(Nullptr_t n) const operator!=(Nullptr_t n) const
{ {
CGAL_triangulation_assertion( n == NULL); CGAL_triangulation_assertion(n == NULL);
return !(*this == n); return !(*this == n);
} }
} // end namespace CGAL
}//namespace
#endif #endif