Curved_kernel -> Circular_kernel_2 [adapt]

This commit is contained in:
Pedro Machado Manhaes de Castro 2006-08-24 14:22:50 +00:00
parent fa528a7453
commit f81514ae14
4 changed files with 0 additions and 1766 deletions

View File

@ -1,262 +0,0 @@
// Copyright (c) 2003-2006 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you may redistribute it under
// the terms of the Q Public License version 1.0.
// See the file LICENSE.QPL distributed with CGAL.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
//
// Author(s) : Monique Teillaud, Sylvain Pion, Constantinos Tsirogiannis
// Partially supported by the IST Programme of the EU as a Shared-cost
// RTD (FET Open) Project under Contract No IST-2000-26473
// (ECG - Effective Computational Geometry for Curves and Surfaces)
// and a STREP (FET Open) Project under Contract No IST-006413
// (ACS -- Algorithms for Complex Shapes)
#ifndef CGAL_CIRCULAR_ARC_WITH_HEXAGON_2_H
#define CGAL_CIRCULAR_ARC_WITH_HEXAGON_2_H
#include <vector>
#include <iterator>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Curved_kernel_converter.h>
#include <CGAL/Bbox_2.h>
#include <CGAL/Filtered_hexagon_curved_kernel/hexagon_primitives.h>
CGAL_BEGIN_NAMESPACE
template < class HK,
class Container = std::vector<Polygon_2<Simple_cartesian<double> > > >
class Circular_arc_with_hexagon_2 {
typedef typename HK::Circular_kernel CK;
typedef typename CK::FT FT;
typedef typename CK::RT RT;
typedef typename CK::Point_2 Point_2;
typedef typename CK::Line_2 Line_2;
typedef typename CK::Circle_2 Circle_2;
typedef typename CK::Circular_arc_point_2 Circular_arc_point_2;
typedef typename CK::Circular_arc_2 Circular_arc_2;
typedef typename CK::Root_of_2 Root_of_2;
typedef CK R;
typedef CGAL::Simple_cartesian<CGAL::Interval_nt<> > FK;
typedef CGAL::Circular_kernel_2< FK,CGAL::Algebraic_kernel_for_circles_2_2<FK::RT> > CK2;
typedef CGAL::Circular_kernel_converter<CK,CK2> Conv;
public:
///////////TYPE DEFINITIONS/////////////
typedef typename Container::iterator Hexagon_iterator;
typedef typename Container::const_iterator Hexagon_const_iterator;
typedef Polygon_2< Simple_cartesian<double> > Hexagon;
///////////Construction/////////////
Circular_arc_with_hexagon_2(){}
Circular_arc_with_hexagon_2(const Circle_2 &c)
: P_arc(c)
{}
Circular_arc_with_hexagon_2(const Circle_2 &support,
const Line_2 &l1, const bool b_l1,
const Line_2 &l2, const bool b_l2)
: P_arc(support,l1,b_l1,l2,b_l2)
{}
Circular_arc_with_hexagon_2(const Circle_2 &c,
const Circle_2 &c1, const bool b_1,
const Circle_2 &c2, const bool b_2)
: P_arc(c,c1,b_1,c2,b_2)
{}
Circular_arc_with_hexagon_2(const Circular_arc_2 &A, const bool b,
const Circle_2 &ccut, const bool b_cut)
: P_arc(A, b, ccut, b_cut)
{}
Circular_arc_with_hexagon_2(const Point_2 &start,
const Point_2 &middle,
const Point_2 &end)
: P_arc(start, middle, end)
{}
Circular_arc_with_hexagon_2(const Circle_2 &support,
const Point_2 &begin,
const Point_2 &end)
: P_arc(support, begin, end)
{}
Circular_arc_with_hexagon_2(const Circle_2 &support,
const Circular_arc_point_2 &begin,
const Circular_arc_point_2 &end)
: P_arc(support, begin, end)
{}
Circular_arc_with_hexagon_2(const Circular_arc_2 &a)
: P_arc(a)
{}
//////////Predicates//////////
bool is_x_monotone() const
{ return P_arc.is_x_monotone();}
bool is_y_monotone() const
{ return P_arc.is_y_monotone();}
bool on_upper_part() const
{ return P_arc.on_upper_part();}
//////////Accessors///////////
const Circular_arc_2& arc () const
{ return P_arc ;}
Hexagon_iterator hexagons_begin()
{ return hexagons.begin();}
Hexagon_iterator hexagons_end()
{ return hexagons.end();}
Hexagon_const_iterator hexagons_begin() const
{ return hexagons.begin();}
Hexagon_const_iterator hexagons_end() const
{ return hexagons.end();}
unsigned hexagon_no() const
{ return hexagons.size();}
///Interface of the inner arc///
typename Qualified_result_of<typename HK::Construct_circular_min_vertex_2,Circular_arc_2>::type
left() const
{ return typename HK::Construct_circular_min_vertex_2()(*this);}
typename Qualified_result_of<typename HK::Construct_circular_max_vertex_2,Circular_arc_2>::type
right() const
{ return typename HK::Construct_circular_max_vertex_2()(*this);}
typename Qualified_result_of<typename HK::Construct_circular_source_vertex_2,Circular_arc_2>::type
source() const
{return typename HK::Construct_circular_source_vertex_2()(*this);}
typename Qualified_result_of<typename HK::Construct_circular_source_vertex_2,Circular_arc_2>::type
target() const
{return typename HK::Construct_circular_target_vertex_2()(*this);}
const Circle_2 & supporting_circle() const
{ return P_arc.supporting_circle();}
const Point_2 & center() const
{ return P_arc.center();}
const FT & squared_radius() const
{ return P_arc.squared_radius();}
Bbox_2 bbox() const
{ return P_arc.bbox();}
///Specific check used for hexagon construction///
bool has_no_hexagons() const
{ return hexagons.empty();}
///Hexagon construction///
void construct_hexagons() const
{
assert(has_no_hexagons());
typedef typename boost::mpl::if_<boost::is_same<typename CK::Definition_tag, typename CK::Curved_tag>, \
Hexagon_construction_with_interval_2<CK,Hexagon>, \
Hexagon_construction_on_lazy_kernel_2<CK,Hexagon> >::type Construct;
Construct()(P_arc,std::back_inserter(hexagons));
}
private:
Circular_arc_2 P_arc;
mutable Container hexagons;
}; // Circular_arc_with_hexagon_2
template < typename HK >
std::ostream &
operator<<(std::ostream & os, const Circular_arc_with_hexagon_2<HK> &a)
{
// The output format is :
// - supporting circle
// - circle c1
// - bool b1
// - circle c2
// - bool b2
return os << a.arc() << " ";
}
template < typename HK >
std::istream &
operator>>(std::istream & is, Circular_arc_with_hexagon_2<HK> &a)
{
typedef typename HK::Circular_kernel CK;
typename CK::Circle_2 s;
typename CK::Circular_arc_point_2 p1;
typename CK::Circular_arc_point_2 p2;
is >> s >> p1 >> p2 ;
if (is)
a = Circular_arc_with_hexagon_2<CK>(s, p1, p2);
return is;
}
template < typename HK >
std::ostream &
print(std::ostream & os, const Circular_arc_with_hexagon_2<HK> &a)
{
return os << "Circular_arc_2( " << std::endl
<< "left : " << a.arc().left() << " , " << std::endl
<< "right : " << a.arc().right() << " , " << std::endl
<< "upper part : " << a.arc().on_upper_part() << std::endl
<< " [[ approximate circle is (x,y,r) : "
<< to_double(a.arc().supporting_circle().center().x()) << " "
<< to_double(a.arc().supporting_circle().center().y()) << " "
<< std::sqrt(to_double(a.arc().supporting_circle()
.squared_radius()))
<< " ]]" << std::endl;
}
CGAL_END_NAMESPACE
#endif // CGAL_CIRCULAR_ARC_WITH_HEXAGON_2_H

View File

@ -1,218 +0,0 @@
// Copyright (c) 2003-2006 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you may redistribute it under
// the terms of the Q Public License version 1.0.
// See the file LICENSE.QPL distributed with CGAL.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
//
// Author(s) : Monique Teillaud, Sylvain Pion, Constantinos Tsirogiannis
// Partially supported by the IST Programme of the EU as a Shared-cost
// RTD (FET Open) Project under Contract No IST-2000-26473
// (ECG - Effective Computational Geometry for Curves and Surfaces)
// and a STREP (FET Open) Project under Contract No IST-006413
// (ACS -- Algorithms for Complex Shapes)
#ifndef CGAL_LINE_ARC_WITH_HEXAGON_2_H
#define CGAL_LINE_ARC_WITH_HEXAGON_2_H
#include <vector>
#include <iterator>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Bbox_2.h>
#include <CGAL/Filtered_hexagon_curved_kernel/hexagon_primitives.h>
CGAL_BEGIN_NAMESPACE
template < class HK >
class Line_arc_with_hexagon_2 {
typedef typename HK::Circular_kernel CK;
typedef typename CK::FT FT;
typedef typename CK::RT RT;
typedef typename CK::Point_2 Point_2;
typedef typename CK::Line_2 Line_2;
typedef typename CK::Segment_2 Segment_2;
typedef typename CK::Circle_2 Circle_2;
typedef typename CK::Circular_arc_point_2 Circular_arc_point_2;
typedef typename CK::Line_arc_2 Line_arc_2;
typedef typename CK::Root_of_2 Root_of_2;
typedef CK R;
typedef CGAL::Simple_cartesian<CGAL::Interval_nt<> > FK;
typedef CGAL::Circular_kernel_2< FK,CGAL::Algebraic_kernel_for_circles_2_2<FK::RT> > CK2;
typedef CGAL::Circular_kernel_converter<CK,CK2> Conv;
public:
///////////TYPE DEFINITIONS/////////////
typedef Line_arc_2 Encapsulated_arc_type;
typedef Polygon_2< Simple_cartesian<double> > Hexagon;
typedef Hexagon* Hexagon_iterator;
typedef const Hexagon * Hexagon_const_iterator;
///////////Construction/////////////
Line_arc_with_hexagon_2(){}
Line_arc_with_hexagon_2(const Line_2 &support,
const Circle_2 &l1, const bool b_l1,
const Circle_2 &l2, const bool b_l2)
: P_arc(support,l1,b_l1,l2,b_l2), hxgn(NULL)
{}
Line_arc_with_hexagon_2(const Line_2 &support,
const Line_2 &l1,
const Line_2 &l2)
: P_arc(support,l1,l2), hxgn(NULL)
{}
Line_arc_with_hexagon_2(const Line_2 &support,
const Circular_arc_point_2 &begin,
const Circular_arc_point_2 &end)
: P_arc(support, begin, end) , hxgn(NULL)
{}
Line_arc_with_hexagon_2(const Segment_2 &s)
: P_arc(s) , hxgn(NULL)
{}
Line_arc_with_hexagon_2(const Point_2 &p1,
const Point_2 &p2)
: P_arc(p1,p2) , hxgn(NULL)
{}
Line_arc_with_hexagon_2(const Line_arc_2 &a)
: P_arc(a) , hxgn(NULL)
{}
//////////Predicates//////////
bool is_vertical() const
{ return P_arc.is_vertical();}
//////////Accessors///////////
const Line_arc_2& arc () const
{ return P_arc ;}
Hexagon_iterator hexagons_begin()
{ return hxgn;}
Hexagon_iterator hexagons_end()
{ return ( (has_no_hexagons())? NULL: hxgn+1);}
Hexagon_const_iterator hexagons_begin() const
{ return hxgn;}
Hexagon_const_iterator hexagons_end() const
{ return ( (has_no_hexagons())? NULL: hxgn+1);}
unsigned hexagon_no() const
{ return ( (has_no_hexagons())? 0 : 1);}
///Interface of the inner arc///
typename Qualified_result_of<typename R::Construct_circular_min_vertex_2,Line_arc_2>::type
left() const
{ return P_arc.left();}
typename Qualified_result_of<typename R::Construct_circular_max_vertex_2,Line_arc_2>::type
right() const
{ return P_arc.right();}
typename Qualified_result_of<typename R::Construct_circular_source_vertex_2,Line_arc_2>::type
source() const
{
return typename R::Construct_circular_source_vertex_2()(this->arc());
}
typename Qualified_result_of<typename R::Construct_circular_target_vertex_2,Line_arc_2>::type
target() const
{
return typename R::Construct_circular_target_vertex_2()(this->arc());
}
const Line_2 & supporting_line() const
{ return P_arc.supporting_line();}
Bbox_2 bbox() const
{ return P_arc.bbox();}
///Specific check used for hexagon construction///
bool has_no_hexagons() const
{ return (hxgn==NULL);}
///Hexagon construction///
void construct_hexagons() const
{
typedef typename boost::mpl::if_<boost::is_same<typename CK::Definition_tag, typename CK::Curved_tag>, \
Hexagon_construction_with_interval_2<CK,Hexagon>, \
Hexagon_construction_on_lazy_kernel_2<CK,Hexagon> >::type Construct;
hxgn = new Hexagon(Construct()(P_arc));
}
private:
Line_arc_2 P_arc;
mutable Hexagon *hxgn;
}; // Line_arc_with_hexagon_2
template < typename HK >
std::ostream &
operator<<(std::ostream & os, const Line_arc_with_hexagon_2<HK> &a)
{
// The output format is :
// Supporting line
// Source endpoint
// Target endpoint
return os << a.arc() << " ";
}
template < typename HK >
std::istream &
operator>>(std::istream & is, Line_arc_with_hexagon_2<HK> &a)
{
typedef typename HK::Circular_kernel CK;
typename CK::Line_2 s;
typename CK::Circular_arc_point_2 p1;
typename CK::Circular_arc_point_2 p2;
is >> s >> p1 >> p2 ;
if (is)
a = Line_arc_with_hexagon_2<HK>(s, p1, p2);
return is;
}
CGAL_END_NAMESPACE
#endif // CGAL_LINE_ARC_WITH_HEXAGON_2_H

View File

@ -1,709 +0,0 @@
// Copyright (c) 2003-2006 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you may redistribute it under
// the terms of the Q Public License version 1.0.
// See the file LICENSE.QPL distributed with CGAL.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
//
// Author(s) : Monique Teillaud, Sylvain Pion, Constantinos Tsirogiannis
// Partially supported by the IST Programme of the EU as a Shared-cost
// RTD (FET Open) Project under Contract No IST-2000-26473
// (ECG - Effective Computational Geometry for Curves and Surfaces)
// and a STREP (FET Open) Project under Contract No IST-006413
// (ACS -- Algorithms for Complex Shapes)
#ifndef CGAL_HEXAGON_FILTERED_PREDICATES_H
#define CGAL_HEXAGON_FILTERED_PREDICATES_H
#include <cassert>
#include <fstream>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/enum.h>
#include <CGAL/Object.h>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Interval_arithmetic.h>
#include <CGAL/Filtered_hexagon_curved_kernel/hexagon_primitives.h>
CGAL_BEGIN_NAMESPACE
namespace Hexagon_functors {
template <class HK>
class In_x_range_2
{
typedef typename HK::Circular_kernel CK;
typedef typename HK::Circular_arc_point_2 Circular_arc_point_2;
typedef typename HK::Circular_arc_2 Circular_arc_2;
typedef typename HK::Line_arc_2 Line_arc_2;
public:
typedef bool result_type;
private:
template <class Arc_2>
result_type
_in_x_range_2(const Arc_2 &a, const Circular_arc_point_2 &p) const
{
std::pair<double,double> pr;
if(a.has_no_hexagons())
a.construct_hexagons();
typename Arc_2::Hexagon_const_iterator hips;
pr = to_interval(p.x());
hips=a.hexagons_begin();
while(hips!=a.hexagons_end())
{
if( (pr.second >= (*(*hips).left_vertex()).x() &&
pr.second <= (*(*hips).right_vertex()).x() ) ||
(pr.first >= (*(*hips).left_vertex()).x() &&
pr.first <= (*(*hips).right_vertex()).x() ) )
return CK().in_x_range_2_object()( a.arc() ,p);
hips++;
}
return false;
}
public:
result_type
operator()( const Circular_arc_2 &a, const Circular_arc_point_2 &p) const
{
CGAL_precondition( a.arc().is_x_monotone());
return _in_x_range_2(a,p);
}
result_type
operator()( const Line_arc_2 &a, const Circular_arc_point_2 &p) const
{return _in_x_range_2(a,p);}
};
template <class HK>
class Construct_circular_source_vertex_2
{
typedef typename HK::Circular_kernel CK;
typedef typename HK::Circular_arc_point_2 Circular_arc_point_2;
typedef typename HK::Circular_arc_2 Circular_arc_2;
public:
typedef Circular_arc_point_2 result_type;
template <typename T>
result_type
operator()(const T& a) const
{return CK().construct_circular_source_vertex_2_object()(a.arc());}
};
template <class HK>
class Construct_circular_target_vertex_2
{
typedef typename HK::Circular_kernel CK;
typedef typename HK::Circular_arc_point_2 Circular_arc_point_2;
typedef typename HK::Circular_arc_2 Circular_arc_2;
public:
typedef Circular_arc_point_2 result_type;
template <typename T>
result_type
operator()(const T& a) const
{return CK().construct_circular_target_vertex_2_object()(a.arc());}
};
template <class HK>
class Construct_circular_min_vertex_2
{
typedef typename HK::Circular_kernel CK;
typedef typename HK::Circular_arc_point_2 Circular_arc_point_2;
typedef typename HK::Circular_arc_2 Circular_arc_2;
public:
typedef Circular_arc_point_2 result_type;
template <typename T>
result_type
operator()(const T& a) const
{ return CK().construct_circular_min_vertex_2_object()(a.arc());}
};
template <class HK>
class Construct_circular_max_vertex_2
{
typedef typename HK::Circular_kernel CK;
typedef typename HK::Circular_arc_point_2 Circular_arc_point_2;
typedef typename HK::Circular_arc_2 Circular_arc_2;
public:
typedef Circular_arc_point_2 result_type;
template <typename T>
result_type
operator()(const T& a) const
{ return CK().construct_circular_max_vertex_2_object()(a.arc()); }
};
template <class HK>
class Has_on_2
{
typedef typename HK::Circular_kernel CK;
typedef typename HK::Circular_arc_2 Circular_arc_2;
typedef typename HK::Circular_arc_point_2 Circular_arc_point_2;
typedef typename HK::Line_arc_2 Line_arc_2;
public:
typedef bool result_type;
private:
template <class Arc_2>
result_type
_has_on_2(const Arc_2 &a, const Circular_arc_point_2 &p) const
{
//Just for the time being
return CK().has_on_2_object()(a.arc(),p);
}
public:
result_type
operator()( const Circular_arc_2 &a,const Circular_arc_point_2 &p ) const
{
CGAL_precondition( a.arc().is_x_monotone());
return _has_on_2(a,p);
}
result_type
operator()( const Line_arc_2 &a, const Circular_arc_point_2 &p ) const
{return _has_on_2(a,p);}
};
template <class HK>
class Is_vertical_2
{
typedef typename HK::Circular_kernel CK;
typedef typename HK::Circular_arc_point_2 Circular_arc_point_2;
typedef typename HK::Circular_arc_2 Circular_arc_2;
public:
typedef bool result_type;
template <typename T>
result_type
operator()(const T& a) const
{ return CK().is_vertical_2_object()(a.arc()); }
};
template <class HK>
class Compare_y_at_x_2
{
typedef typename HK::Circular_kernel CK;
typedef typename HK::Circular_arc_2 Circular_arc_2;
typedef typename HK::Circular_arc_point_2 Circular_arc_point_2;
typedef typename HK::Line_arc_2 Line_arc_2;
typedef typename Circular_arc_2::Hexagon Hexagon;
typedef typename Simple_cartesian<double>::Point_2 Point_2; //Attention!!!
typedef Exact_predicates_inexact_constructions_kernel EK;
public:
typedef Comparison_result result_type;
private:
template <class Arc_2>
result_type
_compare_y_at_x_2(const Circular_arc_point_2 &p,const Arc_2 &a) const
{
CGAL_precondition_code(bool tmp=In_x_range_2<HK>()(a,p));
CGAL_precondition(tmp );
if(a.has_no_hexagons())
a.construct_hexagons();
Comparison_result rel_pos=EQUAL;
Bbox_2 bb = p.bbox();
Hexagon pnt_vec;
pnt_vec.push_back(Point_2(bb.xmin(),bb.ymin()));
pnt_vec.push_back(Point_2(bb.xmin(),bb.ymax()));
pnt_vec.push_back(Point_2(bb.xmax(),bb.ymax()));
pnt_vec.push_back(Point_2(bb.xmax(),bb.ymin()));
typename Arc_2::Hexagon_const_iterator hips=a.hexagons_begin();
while(hips!=a.hexagons_end())
{
if( !(bb.xmin() > hips->right_vertex()->x() || bb.xmax() < hips->left_vertex()->x()) )
if(bb.ymin() > hips->top_vertex()->y())
rel_pos=LARGER;
else if(bb.ymax() < hips->bottom_vertex()->y())
rel_pos=SMALLER;
else
{
rel_pos=EQUAL;
Hexagon hxgn= *hips;
if(CGALi::_do_intersect_hexagon_2(hxgn,pnt_vec))
return CK().compare_y_at_x_2_object()(p,a.arc());
EK::Point_2 a1(hxgn[0].x(),hxgn[0].y()),
a2(hxgn[1].x(),hxgn[1].y()),
a3(pnt_vec[0].x(),pnt_vec[0].y());
if ( EK().orientation_2_object()(a1,a2,a3)==RIGHT_TURN)
rel_pos=SMALLER;
else
rel_pos=LARGER;
}
hips++;
}
return rel_pos;
}
public:
result_type
operator()( const Circular_arc_point_2 &p,const Circular_arc_2 &a ) const
{
CGAL_kernel_precondition( a.arc().is_x_monotone());
return _compare_y_at_x_2(p,a);
}
result_type
operator()( const Circular_arc_point_2 &p,const Line_arc_2 &a ) const
{return _compare_y_at_x_2(p,a);}
};
template <class HK>
class Equal_2
{
typedef typename HK::Circular_kernel CK;
typedef typename HK::Circular_arc_2 Circular_arc_2;
typedef typename HK::Circular_arc_point_2 Circular_arc_point_2;
typedef typename HK::Line_arc_2 Line_arc_2;
public:
typedef bool result_type;
private:
template <class Arc_2>
result_type
_equal_2(const Arc_2 &a,const Arc_2 &b) const
{
if(a.has_no_hexagons())
a.construct_hexagons();
if(b.has_no_hexagons())
b.construct_hexagons();
if(a.hexagon_no() != b.hexagon_no())
return false;
typename Arc_2::Hexagon_const_iterator hips=a.hexagons_begin(),
bips=b.hexagons_begin();
while(hips!=a.hexagons_end())
{
if(hips->size()!=bips->size())
return false;
for(int j=0;j< hips->size() ;j++)
if( (*hips)[j]!=(*bips)[j] )
return false;
hips++;
bips++;
}
return CK().equal_2_object()( a.arc(),b.arc() );
}
public:
result_type
operator()( const Circular_arc_point_2 &a ,
const Circular_arc_point_2 &b ) const
{ return CK().equal_2_object()(a,b);}
result_type
operator()( const Circular_arc_2 &a , const Circular_arc_2 &b ) const
{
CGAL_precondition( a.arc().is_x_monotone());
CGAL_precondition( b.arc().is_x_monotone());
return _equal_2(a,b);
}
result_type
operator()( const Line_arc_2 &a ,
const Line_arc_2 &b ) const
{ return _equal_2(a,b);}
result_type
operator()( const Circular_arc_2 &a ,
const Line_arc_2 &b ) const
{ return false;}
result_type
operator()( const Line_arc_2 &a ,
const Circular_arc_2 &b ) const
{ return false;}
};
template <class HK>
class Do_overlap_2
{
typedef typename HK::Circular_kernel CK;
typedef typename HK::Circular_arc_2 Circular_arc_2;
typedef typename HK::Line_arc_2 Line_arc_2;
public:
typedef bool result_type;
private:
template <class Arc_2>
result_type
_do_overlap_2(const Arc_2 &a, const Arc_2 &b) const
{
if(a.has_no_hexagons())
a.construct_hexagons();
if(b.has_no_hexagons())
b.construct_hexagons();
if(CGALi::do_intersect_hexagons_2( a.hexagons_begin(),a.hexagons_end(),b.hexagons_begin(),b.hexagons_end() ) )
return CK().do_overlap_2_object()(a.arc(),b.arc());
return false;
}
public:
result_type
operator()( const Circular_arc_2 &a , const Circular_arc_2 &b ) const
{
CGAL_precondition( a.arc().is_x_monotone());
CGAL_precondition( b.arc().is_x_monotone());
return _do_overlap_2(a,b);
}
result_type
operator()( const Line_arc_2 &a ,
const Line_arc_2 &b ) const
{ return _do_overlap_2(a,b);}
result_type
operator()( const Circular_arc_2 &a ,
const Line_arc_2 &b ) const
{ return false;}
result_type
operator()( const Line_arc_2 &a ,
const Circular_arc_2 &b ) const
{ return false;}
};
// This predicate cannot be filtered
template < class HK >
class Compare_y_to_right_2
{
typedef typename HK::Circular_kernel CK;
typedef typename HK::Circular_arc_2 Circular_arc_2;
typedef typename HK::Circular_arc_point_2 Circular_arc_point_2;
public:
typedef Comparison_result result_type;
template <typename T1, typename T2>
result_type
operator()(const T1 &a1,
const T2 &a2,
const Circular_arc_point_2 &p) const
{ return CK().compare_y_to_right_2_object()(a1.arc(), a2.arc(), p); }
};
template < class HK >
class Make_x_monotone_2
{
typedef typename HK::Circular_kernel CK;
typedef typename HK::Rcirc_arc_2 Rcirc_arc_2;
typedef typename HK::Circular_arc_2 Circular_arc_2;
typedef typename HK::Line_arc_2 Line_arc_2;
public:
// typedef OutputIterator result_type;
template < class OutputIterator >
OutputIterator
operator()(const Circular_arc_2 &A, OutputIterator res)
{
std::vector<Object> vec;
CK().make_x_monotone_2_object()(A.arc(), std::back_inserter(vec) );
for(unsigned i=0; i<vec.size() ; i++)
{
const Rcirc_arc_2 *tmp_arc;
tmp_arc=object_cast<Rcirc_arc_2>(&vec.at(i));
assert(tmp_arc!=NULL);
*res++ = make_object( Circular_arc_2(*tmp_arc) );
}
return res;
}
template < class OutputIterator >
OutputIterator
operator()(const Line_arc_2 &A, OutputIterator res)
{
*res++ = make_object(A);
return res;
}
};
template < class HK >
class Intersect_2
{
public:
typedef typename HK::Circular_kernel CK;
typedef typename HK::Circular_arc_2 Circular_arc_2;
typedef typename HK::Rcirc_arc_2 Rcirc_arc_2;
typedef typename HK::Rline_arc_2 Rline_arc_2;
typedef typename HK::Circle_2 Circle;
typedef typename HK::Line_arc_2 Line_arc_2;
template < class OutputIterator >
OutputIterator
operator()(const Circle & c1, const Circle & c2, OutputIterator res)
{ return CK().intersect_2_object()(c1,c2,res); }
template < class OutputIterator >
OutputIterator
operator()(const Circular_arc_2 & c1, const Circular_arc_2 & c2,
OutputIterator res)
{
if(c1.has_no_hexagons())
c1.construct_hexagons();
if(c2.has_no_hexagons())
c2.construct_hexagons();
if(!CGALi::do_intersect_hexagons_2(c1.hexagons_begin(),c1.hexagons_end(),
c2.hexagons_begin(),c2.hexagons_end()) )
return res;
std::vector<Object> vec;
CK().intersect_2_object()(c1.arc(),c2.arc(),std::back_inserter(vec));
for(unsigned i=0; i<vec.size() ; i++)
{
const Rcirc_arc_2 *tmp_arc;
if ( (tmp_arc=object_cast<Rcirc_arc_2>(&vec.at(i)) )!=NULL )
*res++ = make_object( Circular_arc_2(*tmp_arc) );
else
*res++ = vec.at(i);
}
return res;
}
template < class OutputIterator >
OutputIterator
operator()(const Line_arc_2 & c1, const Line_arc_2 & c2,
OutputIterator res)
{
if(c1.has_no_hexagons())
c1.construct_hexagons();
if(c2.has_no_hexagons())
c2.construct_hexagons();
if(!CGALi::do_intersect_hexagons_2(c1.hexagons_begin(),c1.hexagons_end(),c2.hexagons_begin(),c2.hexagons_end()) )
return res;
std::vector<Object> vec;
CK().intersect_2_object()(c1.arc(),c2.arc(),std::back_inserter(vec));
for(unsigned i=0; i<vec.size() ; i++)
{
const Rline_arc_2 *tmp_arc;
if ( (tmp_arc=object_cast<Rline_arc_2>(&vec.at(i)) )!=NULL )
*res++ = make_object( Line_arc_2(*tmp_arc) );
else
*res++ = vec.at(i);
}
return res;
}
template < class OutputIterator >
OutputIterator
operator()(const Circular_arc_2 & c1, const Line_arc_2 & c2,
OutputIterator res)
{
if(c1.has_no_hexagons())
c1.construct_hexagons();
if(c2.has_no_hexagons())
c2.construct_hexagons();
if(!CGALi::do_intersect_hexagons_2(c1.hexagons_begin(),c1.hexagons_end(),c2.hexagons_begin(),c2.hexagons_end()) )
return res;
std::vector<Object> vec;
CK().intersect_2_object()(c1.arc(),c2.arc(),std::back_inserter(vec));
for(unsigned i=0; i<vec.size() ; i++)
{
const Rcirc_arc_2 *tmp_arc;
const Rline_arc_2 *tmp_line;
if ( (tmp_arc=object_cast<Rcirc_arc_2>(&vec.at(i)) )!=NULL )
*res++ = make_object( Circular_arc_2(*tmp_arc) );
else if ( (tmp_line=object_cast<Rline_arc_2>(&vec.at(i)) )!=NULL )
*res++ = make_object( Line_arc_2(*tmp_line) );
else
*res++ = vec.at(i);
}
return res;
}
template < class OutputIterator >
OutputIterator
operator()(const Line_arc_2 & c1, const Circular_arc_2 & c2,
OutputIterator res)
{
return operator()(c2,c1,res);
}
};
template < class HK >
class Split_2
{
typedef typename HK::Circular_kernel CK;
typedef typename HK::Rcirc_arc_2 Rcirc_arc_2;
typedef typename HK::Rline_arc_2 Rline_arc_2;
typedef typename HK::Circular_arc_2 Circular_arc_2;
typedef typename HK::Line_arc_2 Line_arc_2;
typedef typename HK::Circular_arc_point_2 Circular_arc_point_2;
public:
typedef void result_type;
result_type
operator()(const Circular_arc_2 &A,
const Circular_arc_point_2 &p,
Circular_arc_2 &ha1, Circular_arc_2 &ha2) const
{
Rcirc_arc_2 ca1 , ca2;
CK().split_2_object()(A.arc(), p, ca1, ca2);
ha1=Circular_arc_2(ca1);
ha2=Circular_arc_2(ca2);
}
result_type
operator()(const Line_arc_2 &A,
const Circular_arc_point_2 &p,
Line_arc_2 &ha1, Line_arc_2 &ha2) const
{
Rline_arc_2 ca1 , ca2;
CK().split_2_object()(A.arc(), p, ca1, ca2);
ha1=Line_arc_2(ca1);
ha2=Line_arc_2(ca2);
}
};
} //Hexagon_functors
CGAL_END_NAMESPACE
#endif // CGAL_HEXAGON_FILTERED_PREDICATES_H

View File

@ -1,577 +0,0 @@
// Copyright (c) 2003-2006 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you may redistribute it under
// the terms of the Q Public License version 1.0.
// See the file LICENSE.QPL distributed with CGAL.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
//
// Author(s) : Monique Teillaud, Sylvain Pion, Constantinos Tsirogiannis
// Partially supported by the IST Programme of the EU as a Shared-cost
// RTD (FET Open) Project under Contract No IST-2000-26473
// (ECG - Effective Computational Geometry for Curves and Surfaces)
// and a STREP (FET Open) Project under Contract No IST-006413
// (ACS -- Algorithms for Complex Shapes)
#ifndef CGAL_HEXAGON_PRIMITIVES_H
#define CGAL_HEXAGON_PRIMITIVES_H
#include <vector>
#include <stack>
#include <CGAL/Polygon_2.h>
#include <CGAL/Bbox_2.h>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/number_utils.h>
#include <CGAL/Line_2.h>
#include <CGAL/Object.h>
#include <CGAL/Lazy.h>
#include <CGAL/Curved_kernel/internal_functions_on_circular_arc_2.h>
#include <CGAL/Curved_kernel_converter.h>
namespace CGAL{
namespace CGALi{
using CGAL::CircularFunctors::advanced_make_xy_monotone;
//#define FILEWRITE
CGAL::Polygon_2 < CGAL::Simple_cartesian< double > >
construct_polygon_from_bbox(const CGAL::Bbox_2& bb )
{
typedef CGAL::Simple_cartesian< double > dK;
typedef dK::Point_2 Point_2;
CGAL::Polygon_2 < dK > pgn;
pgn.insert(pgn.vertices_end(),Point_2(bb.xmin(), bb.ymin()));
pgn.insert(pgn.vertices_end(),Point_2(bb.xmax(), bb.ymin()));
pgn.insert(pgn.vertices_end(),Point_2(bb.xmax(), bb.ymax()));
pgn.insert(pgn.vertices_end(),Point_2(bb.xmin(), bb.ymax()));
return pgn;
}
template <typename CK>
CGAL::Polygon_2 < CGAL::Simple_cartesian< double > >
construct_bounding_hexagon_for_line_arc_2( const typename CK::Line_arc_2 &a)
{
typedef typename CK::Line_arc_2 Line_arc_2;
typedef CGAL::Simple_cartesian<double> dK;
typedef dK::Point_2 Point_2;
typedef CGAL::Polygon_2<dK> Polygon_2;
CGAL::Bbox_2 src_bb= a.source().bbox(),
trgt_bb= a.target().bbox();
if( (src_bb.xmin()<=trgt_bb.xmin() && src_bb.xmax()>=trgt_bb.xmax()) ||
(src_bb.ymin()<=trgt_bb.ymin() && src_bb.ymax()>=trgt_bb.ymax()) ||
(src_bb.xmin()>=trgt_bb.xmin() && src_bb.xmax()<=trgt_bb.xmax()) ||
(src_bb.ymin()>=trgt_bb.ymin() && src_bb.ymax()<=trgt_bb.ymax()) )
return construct_polygon_from_bbox(src_bb+trgt_bb);
Polygon_2 pgn;
bool tmp;
if( (tmp=(src_bb.xmin()<trgt_bb.xmin() && src_bb.ymax()>trgt_bb.ymax())) ||
(trgt_bb.xmin()<src_bb.xmin() && trgt_bb.ymax()>src_bb.ymax()))
{
CGAL::Bbox_2 bb1=(tmp)? src_bb : trgt_bb,
bb2=(tmp)? trgt_bb : src_bb;
pgn.push_back(Point_2(bb1.xmin(),bb1.ymin()));
pgn.push_back(Point_2(bb2.xmin(),bb2.ymin()));
pgn.push_back(Point_2(bb2.xmax(),bb2.ymin()));
pgn.push_back(Point_2(bb2.xmax(),bb2.ymax()));
pgn.push_back(Point_2(bb1.xmax(),bb1.ymax()));
pgn.push_back(Point_2(bb1.xmin(),bb1.ymax()));
}
else if( ( tmp=(src_bb.xmin()<trgt_bb.xmin() && src_bb.ymin()<trgt_bb.ymin())) ||
(trgt_bb.xmin()<src_bb.xmin() && trgt_bb.ymin()<src_bb.ymin()))
{
CGAL::Bbox_2 bb1=(tmp)? src_bb : trgt_bb,
bb2=(tmp)? trgt_bb : src_bb;
pgn.push_back(Point_2(bb1.xmax(),bb1.ymin()));
pgn.push_back(Point_2(bb2.xmax(),bb2.ymin()));
pgn.push_back(Point_2(bb2.xmax(),bb2.ymax()));
pgn.push_back(Point_2(bb2.xmin(),bb2.ymax()));
pgn.push_back(Point_2(bb1.xmin(),bb1.ymax()));
pgn.push_back(Point_2(bb1.xmin(),bb1.ymin()));
}
return pgn;
}
template <typename CK, typename Nested_pair>
CGAL::Polygon_2 < CGAL::Simple_cartesian< double > >
construct_bounding_hexagon_2( const Nested_pair &n)
{
typedef typename CK::Circular_arc_2 Circular_arc_2;
typedef CGAL::Simple_cartesian<double> dK;
typedef dK::Point_2 Point_2;
typedef CGAL::Polygon_2<dK> Polygon_2;
typedef dK::Line_2 Line_2;
typedef dK::Direction_2 Direction_2;
typedef dK::Vector_2 Vector_2;
typedef typename CK::Root_of_2 Root_of_2;
typedef typename CK::FT FT;
Polygon_2 plgn;
const Circular_arc_2 *a=CGAL::object_cast<Circular_arc_2>(&n.first);
// For these and the is_on_ booleans it is required to use a lazy nt
assert(a->is_x_monotone());
assert(a->is_y_monotone());
CGAL::Bbox_2 left_bb(a->left().bbox()),
right_bb(a->right().bbox());
double ymin=(left_bb.ymin()<right_bb.ymin())?left_bb.ymin():right_bb.ymin();
double ymax=(left_bb.ymax()>right_bb.ymax())?left_bb.ymax():right_bb.ymax();
bool is_on_upper_part=n.second.first;
bool is_on_left_side =n.second.second ;
// Define a hypothetical worst case center (_a,_b)
double _a= (is_on_left_side)? right_bb.xmin() : left_bb.xmax() , _b;
if(is_on_upper_part)
_b= (is_on_left_side)? left_bb.ymax(): right_bb.ymax();
else
_b= (is_on_left_side)? left_bb.ymin(): right_bb.ymin();
//Define a worst case radius
double r1= (is_on_left_side)? right_bb.xmin()-left_bb.xmin():
right_bb.xmax()-left_bb.xmax();
double r2= (is_on_upper_part)? right_bb.ymax()-left_bb.ymax():
left_bb.ymin()-right_bb.ymin();
if(!is_on_left_side)
r2=-r2;
Interval_nt<> rad= CGAL::max(r1,r2);
Interval_nt<> sqr2=sqrt(Interval_nt<>(2));
Interval_nt<> _tngx= (is_on_left_side)? Interval_nt<>(_a)-rad/sqr2:
Interval_nt<>(_a)+rad/sqr2;
Interval_nt<> _tngy= (is_on_upper_part)? Interval_nt<>(_b)+rad/sqr2:
Interval_nt<>(_b)-rad/sqr2;
double tngx= (is_on_left_side)? to_interval(_tngx).first:
to_interval(_tngx).second;
double tngy= (is_on_upper_part)? to_interval(_tngy).second:
to_interval(_tngy).first;
// Indicate direction
double dir= ((is_on_upper_part==is_on_left_side)? 1:-1);
CGAL::Interval_nt<> space(to_interval(tngy-dir*tngx).first,to_interval(tngy-dir*tngx).second);
double x1= (is_on_left_side)?left_bb.xmin():right_bb.xmax();
double y2;
if(is_on_upper_part)
y2= (is_on_left_side)? right_bb.ymax(): left_bb.ymax();
else
y2= (is_on_left_side)? right_bb.ymin(): left_bb.ymin();
CGAL::Interval_nt<> _y1= dir*x1+space;
CGAL::Interval_nt<> _x2= (y2-space)*dir;
double y1=(is_on_upper_part)? to_interval(_y1).second: to_interval(_y1).first;
double x2=(is_on_left_side)? to_interval(_x2).first: to_interval(_x2).second;
//Points 1 & 2 or just the 1st one
if (x2<left_bb.xmin()||x2>right_bb.xmax()||y1<ymin||y1>ymax)
plgn.push_back(Point_2(((is_on_left_side)?left_bb.xmin():right_bb.xmax()),
((is_on_upper_part)? ymax : ymin)));
else if (is_on_left_side){
plgn.push_back(Point_2(x1,y1));
plgn.push_back(Point_2(x2,y2));
} else{
plgn.push_back(Point_2(x2,y2));
plgn.push_back(Point_2(x1,y1));
}
//Point 3 -- we get it through the righmost endpoint
if(is_on_upper_part==is_on_left_side)
plgn.push_back(Point_2(right_bb.xmax(),right_bb.ymax()));
else
plgn.push_back(Point_2(right_bb.xmax(),right_bb.ymin()));
if(is_on_upper_part && is_on_left_side &&
(right_bb.ymin()<=left_bb.ymin() || left_bb.xmax()>=right_bb.xmax() ) )
plgn.push_back(Point_2(right_bb.xmax(), left_bb.ymin()));
else if(is_on_upper_part && !is_on_left_side &&
(left_bb.ymin()<=right_bb.ymin() || right_bb.xmin()<= left_bb.xmin()))
plgn.push_back(Point_2(left_bb.xmin(), right_bb.ymin()));
else if(!is_on_upper_part && is_on_left_side &&
(right_bb.ymax()>=left_bb.ymax() || left_bb.xmax()>=right_bb.xmax()))
plgn.push_back(Point_2(right_bb.xmax(), left_bb.ymax()));
else if(!is_on_upper_part && !is_on_left_side &&
(left_bb.ymax()>=right_bb.ymax() || right_bb.xmin()<= left_bb.xmin()))
plgn.push_back(Point_2(left_bb.xmin(), right_bb.ymax()));
else
{
// Point 4
double _x1,_y1;
if(is_on_left_side)
_x1=right_bb.xmax();
else
_x1=right_bb.xmin();
if(is_on_upper_part)
_y1=right_bb.ymin();
else
_y1=right_bb.ymax();
plgn.push_back(Point_2(_x1,_y1));
//Point 5
if(is_on_left_side)
_x1=left_bb.xmax();
else
_x1=left_bb.xmin();
if(is_on_upper_part)
_y1=left_bb.ymin();
else
_y1=left_bb.ymax();
plgn.push_back(Point_2(_x1,_y1));
}
//Point 6
if(is_on_upper_part==is_on_left_side)
plgn.push_back(Point_2(left_bb.xmin(),left_bb.ymin()));
else
plgn.push_back(Point_2(left_bb.xmin(),left_bb.ymax()));
//Reverse (except the last one) the order of the vertices if the hexagon
//is on the upper part , so that all the hexagons
//appear with their vertices in counterclockwise order
if(is_on_upper_part)
{
std::stack<Point_2> stck;
int siz=plgn.size();
for(int i=0;i<siz-1;++i)
stck.push(plgn[i]);
Point_2 last_one=plgn[siz-1];
plgn.clear();
for(int i=0;i<siz-1;++i)
{
plgn.push_back(stck.top());
stck.pop();
}
plgn.push_back(last_one);
}
return plgn;
}
template<typename CK, typename Output_iterator>
Output_iterator construct_bounding_hexagons_2(const typename CK::Circular_arc_2 &a, Output_iterator res)
{
typedef std::pair< bool,bool > Position;
typedef std::pair<CGAL::Object,Position> Verbose_type;
typedef std::vector<Verbose_type > Xy_mon_vector;
typedef CGAL::Simple_cartesian<double> K;
typedef std::vector< CGAL::Polygon_2<K> > Polygon_vector;
Xy_mon_vector xy_arcs;
Polygon_vector polygons;
advanced_make_xy_monotone<CK>(a,std::back_inserter(xy_arcs));
for(unsigned int i=0;i<xy_arcs.size();i++)
*res++=construct_bounding_hexagon_2<CK>(xy_arcs.at(i));
return res;
}
bool _inner_intersect_hexagon_predicate(const CGAL::Polygon_2<Simple_cartesian< double > > &a,
const CGAL::Polygon_2<Simple_cartesian<double> > &b)
{
typedef Simple_cartesian<double> CK;
typedef CK::RT RT;
typedef CK::Point_2 Point_2;
typedef CGAL::Polygon_2<CK> Polygon_2;
typedef Simple_cartesian<Interval_nt<> > intrv_CK;
typedef intrv_CK::Line_2 intrv_Line_2;
typedef intrv_CK::Point_2 intrv_Point_2;
bool pred=(a[0].x()!=a[1].x() && a[0].y()!=a[1].y());
Interval_nt<> d1=a[0].x(),d2=a[0].y();
Interval_nt<> e1=a[1].x(),e2=a[1].y();
intrv_Point_2 a0( d1, d2 );
intrv_Point_2 a1( e1, e2 );
intrv_Line_2 tmp_ln(a0,a1);
if(pred && !tmp_ln.is_vertical())
{
int i;
for(i=0;i<b.size();i++)
{
//if(b[i]==a[0] || b[i]==a[1])
// return true;
std::pair<double,double> app_y=tmp_ln.y_at_x(b[i].x()).pair();
if(b[i].y()>=app_y.first )
if(i==0)
break;
else
return true;
}
if(i!=0)
return false;
}
//Condition implied: the segment used for testing is vertical
if(a[2+pred].x()==a[3+pred].x())
return true;
Interval_nt<> d12=a[2+pred].x(),d22=a[2+pred].y();
Interval_nt<> e12=a[3+pred].x(),e22=a[3+pred].y();
intrv_Point_2 a2( d12, d22 );
intrv_Point_2 a3( e12, e22 );
intrv_Line_2 tmp_ln2(a2,a3);
for(int i=0;i<b.size();i++)
{
std::pair<double,double> app_y=tmp_ln2.y_at_x(b[i].x()).pair();
if(b[i].y()<=app_y.second )
return true;
}
return false;
}
bool _do_intersect_hexagon_2(const CGAL::Polygon_2<Simple_cartesian< double > > &p1,
const CGAL::Polygon_2<Simple_cartesian<double> > &p2)
{
typedef Simple_cartesian<double> CK;
typedef CK::RT RT;
typedef CK::Point_2 Point_2;
typedef CGAL::Polygon_2<CK> Polygon_2;
typedef Simple_cartesian<Interval_nt<> > intrv_CK;
typedef intrv_CK::Line_2 intrv_Line_2;
typedef intrv_CK::Point_2 intrv_Point_2;
Polygon_2 a,b;
bool intersect,tmp=0;
Point_2 frst,scnd;
int size1=p1.size(),
size2=p2.size();
if(size1==4 && size2==4)
return true;
if(size1==4)
{
a=p2;
b=p1;
} else if (size2==4)
{
a=p1;
b=p2;
} else
{
CGAL::Bbox_2 test1(p1.left_vertex()->x(),p1.bottom_vertex()->y(),
p1.right_vertex()->x() ,p1.top_vertex()->y());
for(int i=0;i<size2;i++)
if( tmp=(p2[i].x()>=test1.xmin() && p2[i].x()<=test1.xmax() &&
p2[i].y()>=test1.ymin() && p2[i].y()<=test1.ymax()))
break;
if(tmp)
{
a=p1;
b=p2;
}else
{
a=p2;
b=p1;
}
}
intersect=_inner_intersect_hexagon_predicate(a,b);
if(intersect==false || b.size()==4)
return intersect;
else
return _inner_intersect_hexagon_predicate(b,a);
}
// This is meant for x_monotone and for non-x_monotone cases
template < typename Hex_iterator1, typename Hex_iterator2 >
bool do_intersect_hexagons_2(Hex_iterator1 a_begin, Hex_iterator1 a_end, Hex_iterator2 b_begin, Hex_iterator2 b_end)
{
for(Hex_iterator1 it1=a_begin;it1!=a_end;it1++)
for(Hex_iterator2 it2=b_begin;it2!=b_end;it2++)
if( !(it2->top_vertex()->y() < it1->bottom_vertex()->y() ||
it2->bottom_vertex()->y() > it1->top_vertex()->y() ||
it2->right_vertex()->x() < it1->left_vertex()->x() ||
it2->left_vertex()->x() > it1->right_vertex()->x() ))
{
bool tmp = _do_intersect_hexagon_2(*it1,*it2);
if (tmp)
return true;
}
return false;
}// do_intersect_hexagons_2
}//namespace CGALi
//Lazy like functors that there is no use to be included in the kernel
template < class CK, class Hexagon>
class Hexagon_construction_with_interval_2 {
typedef typename CK::Circular_arc_2 Circular_arc_2;
typedef typename CK::Line_arc_2 Line_arc_2;
typedef CGAL::Simple_cartesian<CGAL::Interval_nt<> > FK;
typedef CGAL::Circular_kernel_2< FK,CGAL::Algebraic_kernel_for_circles_2_2<FK::RT> > CK2;
typedef CGAL::Circular_kernel_converter<CK,CK2> Conv;
public:
template < class OutputIterator>
OutputIterator
operator()(const Circular_arc_2 &a, OutputIterator res) const
{
Conv cnv;
static const bool Protection = true;
try{return CGALi::construct_bounding_hexagons_2<CK2>(cnv(a),res);}
catch (Interval_nt_advanced::unsafe_comparison)
{
CGAL::Protect_FPU_rounding<!Protection> P(CGAL_FE_TONEAREST);
return CGALi::construct_bounding_hexagons_2<CK>(a,res);
}
}
Hexagon operator()(const Line_arc_2 &a) const
{
Conv cnv;
static const bool Protection = true;
try{return CGALi::construct_bounding_hexagon_for_line_arc_2<CK2>(cnv(a));}
catch (Interval_nt_advanced::unsafe_comparison)
{
CGAL::Protect_FPU_rounding<!Protection> P(CGAL_FE_TONEAREST);
return CGALi::construct_bounding_hexagon_for_line_arc_2<CK>(a);
}
}
};
template < class CK, class Hexagon>
class Hexagon_construction_on_lazy_kernel_2 {
typedef typename CK::Circular_arc_2 Circular_arc_2;
typedef typename CK::Line_arc_2 Line_arc_2;
public:
template < class OutputIterator>
OutputIterator
operator()(const Circular_arc_2 &a, OutputIterator res) const
{
static const bool Protection = true;
try{return CGALi::construct_bounding_hexagons_2<typename CK::AK>(a.approx(),res);}
catch (Interval_nt_advanced::unsafe_comparison)
{
CGAL::Protect_FPU_rounding<!Protection> P(CGAL_FE_TONEAREST);
return CGALi::construct_bounding_hexagons_2<typename CK::EK>(a.exact(),res);
}
}
Hexagon operator()(const Line_arc_2 &a) const
{
static const bool Protection = true;
try{return CGALi::construct_bounding_hexagon_for_line_arc_2<typename CK::AK>(a.approx());}
catch (Interval_nt_advanced::unsafe_comparison)
{
CGAL::Protect_FPU_rounding<!Protection> P(CGAL_FE_TONEAREST);
return CGALi::construct_bounding_hexagon_for_line_arc_2<typename CK::EK>(a.exact());
}
}
};
}// namespace CGAL
#endif // CGAL_HEXAGON_PRIMITIVES_H