cleaned-up the code a little bit

This commit is contained in:
Menelaos Karavelas 2004-02-23 22:18:46 +00:00
parent c06e91319c
commit 3251ef3f5c
18 changed files with 333 additions and 806 deletions

View File

@ -25,6 +25,7 @@
#include <CGAL/predicates/Segment_Voronoi_diagram_vertex_C2.h>
#include <CGAL/predicates/Svd_are_same_points_C2.h>
#include <CGAL/predicates/Svd_are_same_segments_C2.h>
#include <CGAL/predicates/Svd_oriented_side_of_bisector_C2.h>
#include <CGAL/predicates/Svd_incircle_2.h>
#include <CGAL/predicates/Svd_finite_edge_interior_2.h>
@ -33,62 +34,4 @@
#include <CGAL/predicates/Svd_do_intersect_C2.h>
#include <CGAL/predicates/Svd_oriented_side_C2.h>
CGAL_BEGIN_NAMESPACE
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
#if 1
template< class K >
class Svd_are_same_points_2
{
public:
typedef typename K::Point_2 Point_2;
typedef typename K::Compare_x_2 compare_x_2;
typedef typename K::Compare_y_2 compare_y_2;
public:
bool operator()(const Point_2& p, const Point_2& q) const
{
if ( compare_x_2()(p, q) != EQUAL ) { return false; }
Comparison_result res = compare_y_2()(p, q);
return res == EQUAL;
}
};
#endif
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
template< class K >
class Svd_is_endpoint_of_segment_2
{
public:
typedef typename K::Point_2 Point_2;
typedef typename K::Segment_2 Segment_2;
typedef typename CGAL::Svd_are_same_points_2<K> Are_same_points_2;
typedef typename K::Compare_x_2 compare_x_2;
typedef typename K::Compare_y_2 compare_y_2;
public:
bool operator()(const Point_2& p, const Segment_2& s) const
{
Are_same_points_2 are_same_points;
return ( are_same_points(p, s.source()) ||
are_same_points(p, s.target()) );
}
};
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
CGAL_END_NAMESPACE
#endif // CGAL_SEGMENT_VORONOI_DIAGRAM_PREDICATES_2_H

View File

@ -411,15 +411,6 @@ svd_oriented_side_of_bisector_ftC2(const typename K::Site_2& p,
Method_tag mtag)
{
typename K::Site_2 site_vec[] = {p, q, t};
#if 0
std::cout << "-----------------------------------------"
<< std::endl;
std::cout << "inside svd_oriented_side_of_bisector_ftC2"
<< std::endl;
std::cout << "p: " << p << std::endl;
std::cout << "q: " << q << std::endl;
std::cout << "t: " << t << std::endl;
#endif
return svd_predicate_C2<Svd_oriented_side_of_bisector_C2,
Oriented_side,K,Method_tag,3>(site_vec);
}

View File

@ -30,53 +30,61 @@
CGAL_BEGIN_NAMESPACE
namespace CGALi {
#if 0
template<class M>
struct Svd_which_base_C2
{
template<class K>
struct Which_base {
typedef Svd_voronoi_vertex_ring_C2<K> Base;
};
};
template <>
struct Svd_which_base_C2<Sqrt_field_tag>
{
template <class K>
struct Which_base {
typedef Svd_voronoi_vertex_sqrt_field_C2<K> Base;
};
};
#else
// with partial specialization:
template<class K,class M> struct Svd_which_base_C2;
template<class M>
struct Svd_which_base_C2
{
template<class K>
struct Which_base {
struct Svd_which_base_C2<K,Ring_tag>
{
typedef Svd_voronoi_vertex_ring_C2<K> Base;
};
};
template <>
struct Svd_which_base_C2<Sqrt_field_tag>
{
template <class K>
struct Which_base {
template<class K>
struct Svd_which_base_C2<K,Sqrt_field_tag>
{
typedef Svd_voronoi_vertex_sqrt_field_C2<K> Base;
};
};
#endif
} // namespace CGALi
//----------------------------------------------------------------------
#if 0
template<class K, class M>
class Svd_voronoi_vertex_2
: public Svd_which_base_C2<M>::template Which_base<K>::Base
{
private:
typedef typename
Svd_which_base_C2<M>::template Which_base<K>::Base Base;
typedef typename Base::Site_2 Site_2;
public:
Svd_voronoi_vertex_2(const Site_2& p, const Site_2& q,
const Site_2& r)
: Base(p, q, r) {}
};
#else
template<class K, class M>
class Svd_voronoi_vertex_C2
: public Svd_which_base_C2<M>::template Which_base<K>::Base
// : public CGALi::Svd_which_base_C2<M>::template Which_base<K>::Base
// using partial specialization:
: public CGALi::Svd_which_base_C2<K,M>::Base
{
private:
typedef typename
Svd_which_base_C2<M>::template Which_base<K>::Base Base;
// typedef typename
// CGALi::Svd_which_base_C2<M>::template Which_base<K>::Base Base;
typedef typename CGALi::Svd_which_base_C2<K,M>::Base Base;
protected:
typedef typename Base::Site_2 Site_2;
@ -85,7 +93,6 @@ public:
const Site_2& r)
: Base(p, q, r) {}
};
#endif
CGAL_END_NAMESPACE

View File

@ -306,33 +306,6 @@ operator<<(Stream& os, const Square_root_1<NT>& x)
{
os << "(" << x.a() << ")+(" << x.b() << ") sqrt{" << x.c() << "}";
return os;
#if 0
if ( CGAL::is_zero(x) ) {
os << "0";
return os;
}
// Square_root_1<NT> One(NT(1), NT(0), x.r());
if ( CGAL::sign(x.a()) != ZERO ) {
os << x.a();
if ( CGAL::is_positive(x.b()) ) {
os << "+";
}
}
if ( CGAL::sign(x.b()) != ZERO &&
CGAL::sign(x.c()) != ZERO ) {
// if ( CGAL::sign(x.b() - One) != ZERO ) {
os << x.b() << " ";
// }
os << "sqrt{" << x.c() << "}";
}
return os;
#endif
}

View File

@ -56,8 +56,10 @@ public:
const NT& a3, const NT& A, const NT& B)
: a0_(a0), a1_(a1), a2_(a2), a3_(a3), A_(A), B_(B)
{
// CGAL_assertion( !(CGAL::is_negative(A_)) );
// CGAL_assertion( !(CGAL::is_negative(B_)) );
#if CHECK_CGAL_PRECONDITIONS
CGAL_precondition( !(CGAL::is_negative(A_)) );
CGAL_precondition( !(CGAL::is_negative(B_)) );
#endif
}
Square_root_2(const Square_root_2<NT>& other)
@ -314,55 +316,6 @@ operator<<(Stream& os, const Square_root_2<NT>& x)
os << "+(" << x.d() << ") sqrt{(" << x.e() << ") (" << x.f()
<< ")}";
return os;
#if 0
if ( CGAL::is_zero(x) ) {
os << "0";
return os;
}
Square_root_2<NT> One(NT(1), NT(0), NT(0), NT(0), x.e(), x.f());
if ( CGAL::sign(x.a()) != ZERO ) {
os << x.a();
if ( CGAL::is_positive(x.b()) ) {
os << "+";
}
}
if ( CGAL::sign(x.b()) != ZERO &&
CGAL::sign(x.e()) != ZERO ) {
if ( CGAL::sign(x.b() - One) != ZERO ) {
os << x.b() << " ";
}
os << "sqrt{" << x.e() << "}";
if ( CGAL::is_positive(x.c()) ) {
os << "+";
}
}
if ( CGAL::sign(x.c()) != ZERO &&
CGAL::sign(x.f()) != ZERO ) {
if ( CGAL::sign(x.c() - One) != ZERO ) {
os << x.c() << " ";
}
os << "sqrt{" << x.f() << "}";
if ( CGAL::is_positive(x.d()) ) {
os << "+";
}
}
if ( CGAL::sign(x.d()) != ZERO &&
CGAL::sign(x.e()) != ZERO &&
CGAL::sign(x.f()) != ZERO ) {
if ( CGAL::sign(x.d() - One) != ZERO ) {
os << x.d() << " ";
}
os << "sqrt{" << x.e() << " " << x.f() << "}";
}
return os;
#endif
}

View File

@ -27,6 +27,7 @@
#include <CGAL/enum.h>
#include <CGAL/predicates/Svd_basic_predicates_C2.h>
#include <CGAL/predicates/Svd_are_same_points_C2.h>
#include <CGAL/predicates/Svd_are_same_segments_C2.h>
CGAL_BEGIN_NAMESPACE
@ -60,25 +61,15 @@ public:
typedef typename Base::Homogeneous_point_2 Homogeneous_point_2;
private:
typedef Svd_are_same_points_C2<K> Are_same_points_C2;
typedef Svd_are_same_points_C2<K> Are_same_points_C2;
typedef Svd_are_same_segments_C2<K> Are_same_segments_C2;
Are_same_points_C2 are_same;
Are_same_points_C2 same_points;
Are_same_segments_C2 same_segments;
private:
//--------------------------------------------------------------------------
bool same_segments(const Site_2& s1, const Site_2& s2) const
{
CGAL_precondition( s1.is_segment() && s2.is_segment() );
return
( are_same(s1.source_site(), s2.source_site()) &&
are_same(s1.target_site(), s2.target_site()) ) ||
( are_same(s1.source_site(), s2.target_site()) &&
are_same(s1.target_site(), s2.source_site()) );
}
//--------------------------------------------------------------------------
void
compute_ppp(const Site_2& sp, const Site_2& sq, const Site_2& sr)
{
@ -113,9 +104,9 @@ private:
v_type = PSS;
bool pq =
are_same(p, q.source_site()) || are_same(p, q.target_site());
same_points(p, q.source_site()) || same_points(p, q.target_site());
bool pr =
are_same(p, r.source_site()) || are_same(p, r.target_site());
same_points(p, r.source_site()) || same_points(p, r.target_site());
Point_2 pp = p.point();
@ -151,15 +142,8 @@ private:
if ( sgn_c1_ == NEGATIVE ) {
a1 = -a1; b1 = -b1; c1_ = -c1_;
} else if ( sgn_c1_ == ZERO ) {
#if 0
if ( !pq ) {
std::cout << "p: " << p << std::endl;
std::cout << "q: " << q << std::endl;
std::cout << "r: " << r << std::endl;
}
#endif
CGAL_assertion( pq );
if ( are_same(p, q.target_site()) ) {
if ( same_points(p, q.target_site()) ) {
a1 = -a1; b1 = -b1; c1_ = -c1_;
}
}
@ -168,7 +152,7 @@ private:
a2 = -a2; b2 = -b2; c2_ = -c2_;
} else if ( sgn_c2_ == ZERO ) {
CGAL_assertion( pr );
if ( are_same(p, r.source_site()) ) {
if ( same_points(p, r.source_site()) ) {
a2 = -a2; b2 = -b2; c2_ = -c2_;
}
}
@ -323,12 +307,12 @@ private:
RT cq_ = a * qq.x() + b * qq.y() + c;
if ( are_same(p, r.source_site()) ||
are_same(p, r.target_site()) ) {
if ( same_points(p, r.source_site()) ||
same_points(p, r.target_site()) ) {
c_ = RT(0);
}
if ( are_same(q, r.source_site()) ||
are_same(q, r.target_site()) ) {
if ( same_points(q, r.source_site()) ||
same_points(q, r.target_site()) ) {
cq_ = RT(0);
}
@ -392,7 +376,6 @@ private:
is_on_positive_halfspace(const Site_2& supp,
const Site_2& s, const Line_2& l) const
{
#if 1
CGAL_precondition( supp.is_segment() && s.is_segment() );
if ( same_segments(supp.supporting_site(),
@ -400,13 +383,13 @@ private:
return false;
}
if ( are_same(supp.source_site(), s.source_site()) ||
are_same(supp.target_site(), s.source_site()) ) {
if ( same_points(supp.source_site(), s.source_site()) ||
same_points(supp.target_site(), s.source_site()) ) {
return oriented_side_of_line(l, s.target()) == ON_POSITIVE_SIDE;
}
if ( are_same(supp.source_site(), s.target_site()) ||
are_same(supp.target_site(), s.target_site()) ) {
if ( same_points(supp.source_site(), s.target_site()) ||
same_points(supp.target_site(), s.target_site()) ) {
return oriented_side_of_line(l, s.source()) == ON_POSITIVE_SIDE;
}
@ -422,7 +405,6 @@ private:
return oriented_side_of_line(l, s.source()) == ON_POSITIVE_SIDE;
}
#endif
return Base::is_on_positive_halfspace(l, s.segment());
}
@ -663,23 +645,13 @@ private:
}
//--------------------------------------------------------------------------
#if 0
bool are_identical(const Point_2& p, const Point_2& q) const
{
return (p == q);
}
#endif
//--------------------------------------------------------------------------
bool is_endpoint_of(const Site_2& p, const Site_2& s) const
{
CGAL_precondition( p.is_point() && s.is_segment() );
return ( are_same(p, s.source_site()) ||
are_same(p, s.target_site()) );
return ( same_points(p, s.source_site()) ||
same_points(p, s.target_site()) );
}
@ -761,9 +733,9 @@ private:
CGAL_precondition( t.is_point() );
use_result = false;
if ( ( p_.is_point() && are_same(p_, t) ) ||
( q_.is_point() && are_same(q_, t) ) ||
( r_.is_point() && are_same(r_, t) ) ) {
if ( ( p_.is_point() && same_points(p_, t) ) ||
( q_.is_point() && same_points(q_, t) ) ||
( r_.is_point() && same_points(r_, t) ) ) {
use_result = true;
return ZERO;
}
@ -870,10 +842,8 @@ private:
Sqrt_3 Rs1 =
CGAL::square(ux - tx * uz) + CGAL::square(uy - ty * uz);
// Sign s_vz = CGAL::sign(vz);
Sign s_Q = CGAL::sign(Rs1 - Rs);
// return Sign(s_vz * s_Q);
return s_Q;
}
@ -1151,18 +1121,18 @@ private:
}
Sign d1, d2;
if ( ( p_.is_point() && are_same(p_, t.source_site()) ) ||
( q_.is_point() && are_same(q_, t.source_site()) ) ||
( r_.is_point() && are_same(r_, t.source_site()) ) ) {
if ( ( p_.is_point() && same_points(p_, t.source_site()) ) ||
( q_.is_point() && same_points(q_, t.source_site()) ) ||
( r_.is_point() && same_points(r_, t.source_site()) ) ) {
d1 = ZERO;
} else {
d1 = incircle_p(t.source_site());
}
if ( d1 == NEGATIVE ) { return NEGATIVE; }
if ( ( p_.is_point() && are_same(p_, t.target_site()) ) ||
( q_.is_point() && are_same(q_, t.target_site()) ) ||
( r_.is_point() && are_same(r_, t.target_site()) ) ) {
if ( ( p_.is_point() && same_points(p_, t.target_site()) ) ||
( q_.is_point() && same_points(q_, t.target_site()) ) ||
( r_.is_point() && same_points(r_, t.target_site()) ) ) {
d2 = ZERO;
} else {
d2 = incircle_p(t.target_site());
@ -1173,7 +1143,6 @@ private:
Line_2 l = compute_supporting_line(t.supporting_segment());
Sign sl = incircle(l, type);
// this is the old code
if ( sl == POSITIVE ) { return sl; }
Oriented_side os1 = oriented_side(l, t.source(), type);
@ -1199,8 +1168,8 @@ private:
if ( is_degenerate_Voronoi_circle() ) {
// case 1: the new segment is not adjacent to the center of the
// degenerate Voronoi circle
if ( !are_same( p_ref(), t.source_site() ) &&
!are_same( p_ref(), t.target_site() ) ) {
if ( !same_points( p_ref(), t.source_site() ) &&
!same_points( p_ref(), t.target_site() ) ) {
return POSITIVE;
}
@ -1223,46 +1192,39 @@ private:
t.supporting_site()) ) {
return ZERO;
}
#if 0
if ( ( r_.is_point() && are_same(p_ref(), r_) ) ||
( q_.is_point() && are_same(p_ref(), q_) ) ||
( p_.is_point() && are_same(p_ref(), p_) ) ) {
#endif
Site_2 pr;
Site_2 sp, sq;
if ( p_.is_point() ) {
CGAL_assertion( q_.is_segment() && r_.is_segment() );
pr = p_;
sp = q_;
sq = r_;
} else if ( q_.is_point() ) {
CGAL_assertion( r_.is_segment() && p_.is_segment() );
pr = q_;
sp = r_;
sq = p_;
} else {
CGAL_assertion( p_.is_segment() && q_.is_segment() );
pr = r_;
sp = p_;
sq = q_;
}
Point_2 pq = sq.source(), pp = sp.source(), pt = t.source();
if ( are_same(sp.source_site(), pr) ) { pp = sp.target(); }
if ( are_same(sq.source_site(), pr) ) { pq = sq.target(); }
if ( are_same( t.source_site(), pr) ) { pt = t.target(); }
Point_2 pr_ = pr.point();
if ( CGAL::orientation(pr_, pp, pt) == LEFT_TURN &&
CGAL::orientation(pr_, pq, pt) == RIGHT_TURN ) {
return NEGATIVE;
}
return ZERO;
#if 0
Site_2 pr;
Site_2 sp, sq;
if ( p_.is_point() ) {
CGAL_assertion( q_.is_segment() && r_.is_segment() );
pr = p_;
sp = q_;
sq = r_;
} else if ( q_.is_point() ) {
CGAL_assertion( r_.is_segment() && p_.is_segment() );
pr = q_;
sp = r_;
sq = p_;
} else {
CGAL_assertion( p_.is_segment() && q_.is_segment() );
pr = r_;
sp = p_;
sq = q_;
}
#endif
Point_2 pq = sq.source(), pp = sp.source(), pt = t.source();
if ( same_points(sp.source_site(), pr) ) { pp = sp.target(); }
if ( same_points(sq.source_site(), pr) ) { pq = sq.target(); }
if ( same_points( t.source_site(), pr) ) { pt = t.target(); }
Point_2 pr_ = pr.point();
if ( CGAL::orientation(pr_, pp, pt) == LEFT_TURN &&
CGAL::orientation(pr_, pq, pt) == RIGHT_TURN ) {
return NEGATIVE;
}
return ZERO;
} // if ( is_degenerate_Voronoi_circle() )
Sign s(ZERO);
@ -1307,22 +1269,6 @@ public:
//--------------------------------------------------------------------------
public:
// THIS METHOD SHOULD BE PRIVATE AND SHOULD NOT BE USED IN THE
// PREDICATES (MAYBE I AM WRONG ON THIS????) IN ANY CASE CALLS TO
// THIS METHOD SHOULD BE ELIMINATED AS MUCH AS POSSIBLE; ALSO I NEED
// TO WRITE A SPECIAL VERSION FOR THE RING_TAG CASE
#if 0
bool is_same_point(const Point_2& p, Method_tag) const
{
Comparison_result res = CGAL::compare(x(), p.x());
if ( res != EQUAL ) { return false; }
return (CGAL::compare(y(), p.y()) == EQUAL);
}
#endif
private:
//--------------------------------------------------------------------------
@ -1506,11 +1452,6 @@ private:
CGAL_END_NAMESPACE

View File

@ -28,6 +28,7 @@
#include <CGAL/enum.h>
#include <CGAL/predicates/Svd_basic_predicates_C2.h>
#include <CGAL/predicates/Svd_are_same_points_C2.h>
#include <CGAL/predicates/Svd_are_same_segments_C2.h>
CGAL_BEGIN_NAMESPACE
@ -57,26 +58,16 @@ public:
typedef typename Base::Homogeneous_point_2 Homogeneous_point_2;
typedef Svd_are_same_points_C2<K> Are_same_points_C2;
typedef Svd_are_same_points_C2<K> Are_same_points_C2;
typedef Svd_are_same_segments_C2<K> Are_same_segments_C2;
Are_same_points_C2 are_same;
Are_same_points_C2 same_points;
Are_same_segments_C2 same_segments;
private:
//--------------------------------------------------------------------------
bool same_segments(const Site_2& s1, const Site_2& s2) const
{
CGAL_precondition( s1.is_segment() && s2.is_segment() );
return
( are_same(s1.source_site(), s2.source_site()) &&
are_same(s1.target_site(), s2.target_site()) ) ||
( are_same(s1.source_site(), s2.target_site()) &&
are_same(s1.target_site(), s2.source_site()) );
}
//--------------------------------------------------------------------------
void
compute_ppp(const Site_2& sp, const Site_2& sq, const Site_2& sr)
{
@ -109,9 +100,9 @@ private:
v_type = PSS;
bool pq =
are_same(p, q.source_site()) || are_same(p, q.target_site());
same_points(p, q.source_site()) || same_points(p, q.target_site());
bool pr =
are_same(p, r.source_site()) || are_same(p, r.target_site());
same_points(p, r.source_site()) || same_points(p, r.target_site());
Point_2 pp = p.point();
@ -146,7 +137,7 @@ private:
} else if ( sgn_c1_ == ZERO ) {
CGAL_assertion( pq );
if ( are_same(p, q.target_site()) ) {
if ( same_points(p, q.target_site()) ) {
a1 = -a1; b1 = -b1; c1_ = -c1_;
}
}
@ -156,7 +147,7 @@ private:
} else if ( sgn_c2_ == ZERO ) {
CGAL_assertion( pr );
if ( are_same(p, r.source_site()) ) {
if ( same_points(p, r.source_site()) ) {
a2 = -a2; b2 = -b2; c2_ = -c2_;
}
}
@ -255,8 +246,6 @@ private:
r.is_segment() );
v_type = PPS;
// std::cout << "pps check 0" << std::endl;
FT a, b, c;
compute_supporting_line(r.supporting_segment(), a, b, c);
@ -265,17 +254,15 @@ private:
FT c_ = a * pp.x() + b * pp.y() + c;
FT cq_ = a * qq.x() + b * qq.y() + c;
if ( are_same(p, r.source_site()) ||
are_same(p, r.target_site()) ) {
if ( same_points(p, r.source_site()) ||
same_points(p, r.target_site()) ) {
c_ = FT(0);
}
if ( are_same(q, r.source_site()) ||
are_same(q, r.target_site()) ) {
if ( same_points(q, r.source_site()) ||
same_points(q, r.target_site()) ) {
cq_ = FT(0);
}
// std::cout << "cq_ : " << cq_ << std::endl;
Sign s = CGAL::sign(c_);
if ( s == NEGATIVE ) {
@ -298,8 +285,6 @@ private:
Comparison_result res = CGAL::compare( c_, cq_ );
// std::cout << "res: " << res << std::endl;
if ( res == EQUAL ) {
FT e1 = CGAL::square(c_);
FT J = nl * (a * n_ + FT(4) * c_ * x_) - FT(4) * a * e1;
@ -338,7 +323,6 @@ private:
is_on_positive_halfspace(const Site_2& supp,
const Site_2& s, const Line_2& l) const
{
#if 1
CGAL_precondition( supp.is_segment() && s.is_segment() );
if ( same_segments(supp.supporting_site(),
@ -346,13 +330,13 @@ private:
return false;
}
if ( are_same(supp.source_site(), s.source_site()) ||
are_same(supp.target_site(), s.source_site()) ) {
if ( same_points(supp.source_site(), s.source_site()) ||
same_points(supp.target_site(), s.source_site()) ) {
return oriented_side_of_line(l, s.target()) == ON_POSITIVE_SIDE;
}
if ( are_same(supp.source_site(), s.target_site()) ||
are_same(supp.target_site(), s.target_site()) ) {
if ( same_points(supp.source_site(), s.target_site()) ||
same_points(supp.target_site(), s.target_site()) ) {
return oriented_side_of_line(l, s.source()) == ON_POSITIVE_SIDE;
}
@ -368,7 +352,6 @@ private:
return oriented_side_of_line(l, s.source()) == ON_POSITIVE_SIDE;
}
#endif
return Base::is_on_positive_halfspace(l, s.segment());
}
@ -381,10 +364,6 @@ private:
CGAL_precondition( sp.is_segment() && sq.is_segment() &&
sr.is_segment() );
#if 0
std::cout << "inside orient lines" << std::endl;
#endif
Line_2 l[3];
l[0] = compute_supporting_line(sp.supporting_segment());
l[1] = compute_supporting_line(sq.supporting_segment());
@ -392,18 +371,12 @@ private:
bool is_oriented[3] = {false, false, false};
// Segment_2 p = sp.segment(), q = sq.segment(), r = sr.segment();
// if ( is_on_positive_halfspace(l[0], q) ||
// is_on_positive_halfspace(l[0], r) ) {
if ( is_on_positive_halfspace(sp, sq, l[0]) ||
is_on_positive_halfspace(sp, sr, l[0]) ) {
is_oriented[0] = true;
} else {
l[0] = opposite_line(l[0]);
// if ( is_on_positive_halfspace(l[0], q) ||
// is_on_positive_halfspace(l[0], r) ) {
if ( is_on_positive_halfspace(sp, sq, l[0]) ||
is_on_positive_halfspace(sp, sr, l[0]) ) {
is_oriented[0] = true;
@ -412,15 +385,11 @@ private:
}
}
// if ( is_on_positive_halfspace(l[1], p) ||
// is_on_positive_halfspace(l[1], r) ) {
if ( is_on_positive_halfspace(sq, sp, l[1]) ||
is_on_positive_halfspace(sq, sr, l[1]) ) {
is_oriented[1] = true;
} else {
l[1] = opposite_line(l[1]);
// if ( is_on_positive_halfspace(l[1], p) ||
// is_on_positive_halfspace(l[1], r) ) {
if ( is_on_positive_halfspace(sq, sp, l[1]) ||
is_on_positive_halfspace(sq, sr, l[1]) ) {
is_oriented[1] = true;
@ -429,15 +398,11 @@ private:
}
}
// if ( is_on_positive_halfspace(l[2], p) ||
// is_on_positive_halfspace(l[2], q) ) {
if ( is_on_positive_halfspace(sr, sp, l[2]) ||
is_on_positive_halfspace(sr, sq, l[2]) ) {
is_oriented[2] = true;
} else {
l[2] = opposite_line(l[2]);
// if ( is_on_positive_halfspace(l[2], p) ||
// is_on_positive_halfspace(l[2], q) ) {
if ( is_on_positive_halfspace(sr, sp, l[2]) ||
is_on_positive_halfspace(sr, sq, l[2]) ) {
is_oriented[2] = true;
@ -617,21 +582,13 @@ private:
}
//--------------------------------------------------------------------------
#if 0
bool are_identical(const Point_2& p, const Point_2& q) const
{
return (p == q);
}
#endif
//--------------------------------------------------------------------------
bool is_endpoint_of(const Site_2& p, const Site_2& s) const
{
CGAL_precondition( p.is_point() && s.is_segment() );
return ( are_same(p, s.source_site()) ||
are_same(p, s.target_site()) );
return ( same_points(p, s.source_site()) ||
same_points(p, s.target_site()) );
}
@ -654,9 +611,9 @@ private:
CGAL_precondition( t.is_point() );
use_result = false;
if ( ( p_.is_point() && are_same(p_, t) ) ||
( q_.is_point() && are_same(q_, t) ) ||
( r_.is_point() && are_same(r_, t) ) ) {
if ( ( p_.is_point() && same_points(p_, t) ) ||
( q_.is_point() && same_points(q_, t) ) ||
( r_.is_point() && same_points(r_, t) ) ) {
use_result = true;
return ZERO;
}
@ -725,8 +682,6 @@ private:
FT d2 = CGAL::square(x() - t.x()) +
CGAL::square(y() - t.y());
// std::cout << "r2, d2: " << r2 << ", " << d2 << std::endl;
return Sign( CGAL::compare(d2, r2) );
}
@ -796,10 +751,6 @@ private:
{
CGAL_precondition( t.is_segment() );
#if 0
std::cout << "inside incircle_s with int" << std::endl;
#endif
if ( v_type == PPP || v_type == PPS ) {
if ( p_.is_point() && q_.is_point() &&
is_endpoint_of(p_, t) && is_endpoint_of(q_, t) ) {
@ -836,18 +787,18 @@ private:
}
Sign d1, d2;
if ( ( p_.is_point() && are_same(p_, t.source_site()) ) ||
( q_.is_point() && are_same(q_, t.source_site()) ) ||
( r_.is_point() && are_same(r_, t.source_site()) ) ) {
if ( ( p_.is_point() && same_points(p_, t.source_site()) ) ||
( q_.is_point() && same_points(q_, t.source_site()) ) ||
( r_.is_point() && same_points(r_, t.source_site()) ) ) {
d1 = ZERO;
} else {
d1 = incircle_p(t.source_site());
}
if ( d1 == NEGATIVE ) { return NEGATIVE; }
if ( ( p_.is_point() && are_same(p_, t.target_site()) ) ||
( q_.is_point() && are_same(q_, t.target_site()) ) ||
( r_.is_point() && are_same(r_, t.target_site()) ) ) {
if ( ( p_.is_point() && same_points(p_, t.target_site()) ) ||
( q_.is_point() && same_points(q_, t.target_site()) ) ||
( r_.is_point() && same_points(r_, t.target_site()) ) ) {
d2 = ZERO;
} else {
d2 = incircle_p(t.target_site());
@ -857,7 +808,6 @@ private:
Line_2 l = compute_supporting_line(t.supporting_segment());
Sign sl = incircle(l);
// this is the old code
if ( sl == POSITIVE ) { return sl; }
Oriented_side os1 = oriented_side(l, t.source());
@ -880,19 +830,11 @@ private:
{
CGAL_precondition( t.is_segment() );
#if 0
std::cout << "inside incircle_s without int" << std::endl;
#endif
if ( is_degenerate_Voronoi_circle() ) {
// case 1: the new segment is not adjacent to the center of the
// degenerate Voronoi circle
#if 0
std::cout << "incircle_s:: The Voronoi circle is degenerate: "
<< t << std::endl;
#endif
if ( !are_same( p_ref(), t.source_site() ) &&
!are_same( p_ref(), t.target_site() ) ) {
if ( !same_points( p_ref(), t.source_site() ) &&
!same_points( p_ref(), t.target_site() ) ) {
return POSITIVE;
}
@ -916,52 +858,39 @@ private:
return ZERO;
}
#if 0
if ( ( r_.is_point() && are_same(p_ref(), r_) ) ||
( q_.is_point() && are_same(p_ref(), q_) ) ||
( p_.is_point() && are_same(p_ref(), p_) ) ) {
#endif
Site_2 pr;
Site_2 sp, sq;
if ( p_.is_point() ) {
CGAL_assertion( q_.is_segment() && r_.is_segment() );
pr = p_;
sp = q_;
sq = r_;
} else if ( q_.is_point() ) {
CGAL_assertion( r_.is_segment() && p_.is_segment() );
pr = q_;
sp = r_;
sq = p_;
} else {
CGAL_assertion( p_.is_segment() && q_.is_segment() );
pr = r_;
sp = p_;
sq = q_;
}
Point_2 pq = sq.source(), pp = sp.source(), pt = t.source();
if ( are_same(sp.source_site(), pr) ) { pp = sp.target(); }
if ( are_same(sq.source_site(), pr) ) { pq = sq.target(); }
if ( are_same( t.source_site(), pr) ) { pt = t.target(); }
Point_2 pr_ = pr.point();
if ( CGAL::orientation(pr_, pp, pt) == LEFT_TURN &&
CGAL::orientation(pr_, pq, pt) == RIGHT_TURN ) {
return NEGATIVE;
}
return ZERO;
#if 0
Site_2 pr;
Site_2 sp, sq;
if ( p_.is_point() ) {
CGAL_assertion( q_.is_segment() && r_.is_segment() );
pr = p_;
sp = q_;
sq = r_;
} else if ( q_.is_point() ) {
CGAL_assertion( r_.is_segment() && p_.is_segment() );
pr = q_;
sp = r_;
sq = p_;
} else {
CGAL_assertion( p_.is_segment() && q_.is_segment() );
pr = r_;
sp = p_;
sq = q_;
}
#endif
} // if ( is_degenerate_Voronoi_circle() )
#if 0
std::cout << "inside incircle_s without int: non-degenerate VV"
<< std::endl;
#endif
Point_2 pq = sq.source(), pp = sp.source(), pt = t.source();
if ( same_points(sp.source_site(), pr) ) { pp = sp.target(); }
if ( same_points(sq.source_site(), pr) ) { pq = sq.target(); }
if ( same_points( t.source_site(), pr) ) { pt = t.target(); }
Point_2 pr_ = pr.point();
if ( CGAL::orientation(pr_, pp, pt) == LEFT_TURN &&
CGAL::orientation(pr_, pq, pt) == RIGHT_TURN ) {
return NEGATIVE;
}
return ZERO;
} // if ( is_degenerate_Voronoi_circle() )
Sign s = incircle_s(t, 0);
@ -991,22 +920,6 @@ public:
//--------------------------------------------------------------------------
public:
// THIS METHOD SHOULD BE PRIVATE AND SHOULD NOT BE USED IN THE
// PREDICATES (MAYBE I AM WRONG ON THIS????) IN ANY CASE CALLS TO
// THIS METHOD SHOULD BE ELIMINATED AS MUCH AS POSSIBLE; ALSO I NEED
// TO WRITE A SPECIAL VERSION FOR THE RING_TAG CASE
#if 0
bool is_same_point(const Point_2& p) const
{
Comparison_result res = CGAL::compare(x(), p.x());
if ( res != EQUAL ) { return false; }
return (CGAL::compare(y(), p.y()) == EQUAL);
}
#endif
private:
//--------------------------------------------------------------------------

View File

@ -867,22 +867,6 @@ public:
//--------------------------------------------------------------------------
public:
// THIS METHOD SHOULD BE PRIVATE AND SHOULD NOT BE USED IN THE
// PREDICATES (MAYBE I AM WRONG ON THIS????) IN ANY CASE CALLS TO
// THIS METHOD SHOULD BE ELIMINATED AS MUCH AS POSSIBLE; ALSO I NEED
// TO WRITE A SPECIAL VERSION FOR THE RING_TAG CASE
#if 0
bool is_same_point(const Point_2& p) const
{
Comparison_result res = CGAL::compare(x(), p.x());
if ( res != EQUAL ) { return false; }
return (CGAL::compare(y(), p.y()) == EQUAL);
}
#endif
private:
//--------------------------------------------------------------------------

View File

@ -64,14 +64,7 @@ public:
p.supporting_segment(1) };
Segment_2 t[2] = { q.supporting_segment(0),
q.supporting_segment(1) };
#if 0
bool b[2][2];
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
b[i][j] = are_same(s[i], t[j]);
}
}
#endif
return ( are_same(s[0], t[0]) && are_same(s[1], t[1]) ) ||
( are_same(s[0], t[1]) && are_same(s[1], t[0]) );
}

View File

@ -0,0 +1,56 @@
// Copyright (c) 2003,2004 INRIA Sophia-Antipolis (France) and
// Notre Dame University (U.S.A.). 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.
//
// $Source$
// $Revision$ $Date$
// $Name$
//
// Author(s) : Menelaos Karavelas <mkaravel@cse.nd.edu>
#include <CGAL/predicates/Svd_are_same_points_C2.h>
#ifndef CGAL_SVD_ARE_SAME_SEGMENTS_C2_H
#define CGAL_SVD_ARE_SAME_SEGMENTS_C2_H
CGAL_BEGIN_NAMESPACE
template<class K>
class Svd_are_same_segments_C2
{
private:
typedef typename K::Site_2 Site_2;
typedef Svd_are_same_points_C2<K> Are_same_points_2;
private:
Are_same_points_2 same_points;
public:
bool operator()(const Site_2& p, const Site_2& q) const
{
CGAL_precondition( p.is_segment() && q.is_segment() );
return
( same_points(p.source_site(), q.source_site()) &&
same_points(p.target_site(), q.target_site()) ) ||
( same_points(p.source_site(), q.target_site()) &&
same_points(p.target_site(), q.source_site()) );
}
};
CGAL_END_NAMESPACE
#endif // CGAL_SVD_ARE_SAME_SEGMENTS_C2_H

View File

@ -55,8 +55,16 @@ public:
typedef typename Number_type_traits<RT>::Has_sqrt RT_Has_sqrt;
typedef typename Number_type_traits<FT>::Has_sqrt FT_Has_sqrt;
static RT_Has_sqrt rt_has_sqrt;
static FT_Has_sqrt ft_has_sqrt;
static const RT_Has_sqrt& rt_has_sqrt() {
static RT_Has_sqrt has_sqrt;
return has_sqrt;
}
static FT_Has_sqrt ft_has_sqrt() {
static FT_Has_sqrt has_sqrt;
return has_sqrt;
}
class Line_2
{
@ -106,12 +114,12 @@ public:
// CONVERSIONS
//-------------------------------------------------------------------
static FT compute_sqrt(const FT& x, Tag_true)
static FT compute_sqrt(const FT& x, const Tag_true&)
{
return CGAL::sqrt( x );
}
static FT compute_sqrt(const FT& x, Tag_false)
static FT compute_sqrt(const FT& x, const Tag_false&)
{
return FT( CGAL::sqrt( CGAL::to_double(x) ) );
}
@ -119,18 +127,15 @@ public:
static
FT to_ft(const Sqrt_1& x)
{
// FT sqrt_c = CGAL::sqrt(x.c());
FT sqrt_c = compute_sqrt( x.c(), ft_has_sqrt );
FT sqrt_c = compute_sqrt( x.c(), ft_has_sqrt() );
return x.a() + x.b() * sqrt_c;
}
static
FT to_ft(const Sqrt_3& x)
{
// FT sqrt_e = CGAL::sqrt( to_ft(x.e()) );
// FT sqrt_f = CGAL::sqrt( to_ft(x.f()) );
FT sqrt_e = compute_sqrt( to_ft(x.e()), ft_has_sqrt );
FT sqrt_f = compute_sqrt( to_ft(x.f()), ft_has_sqrt );
FT sqrt_e = compute_sqrt( to_ft(x.e()), ft_has_sqrt() );
FT sqrt_f = compute_sqrt( to_ft(x.f()), ft_has_sqrt() );
FT sqrt_ef = sqrt_e * sqrt_f;
return to_ft(x.a()) + to_ft(x.b()) * sqrt_e
+ to_ft(x.c()) * sqrt_f + to_ft(x.d()) * sqrt_ef;
@ -144,15 +149,8 @@ public:
static
Line_2 compute_supporting_line(const Segment_2& s)
{
#if 1
RT a, b, c;
compute_supporting_line(s, a, b, c);
#else
RT a = s.source().y() - s.target().y();
RT b = s.target().x() - s.source().x();
RT c = s.source().x() * s.target().y()
- s.target().x() * s.source().y();
#endif
return Line_2(a, b, c);
}
@ -322,15 +320,6 @@ public:
};
template<class K>
typename Svd_basic_predicates_C2<K>::RT_Has_sqrt
Svd_basic_predicates_C2<K>::rt_has_sqrt =
Svd_basic_predicates_C2<K>::RT_Has_sqrt();
template<class K>
typename Svd_basic_predicates_C2<K>::FT_Has_sqrt
Svd_basic_predicates_C2<K>::ft_has_sqrt =
Svd_basic_predicates_C2<K>::FT_Has_sqrt();
CGAL_END_NAMESPACE

View File

@ -27,6 +27,7 @@
#include <CGAL/determinant.h>
#include <CGAL/predicates/Svd_basic_predicates_C2.h>
#include <CGAL/predicates/Svd_are_same_points_C2.h>
#include <CGAL/predicates/Svd_are_same_segments_C2.h>
CGAL_BEGIN_NAMESPACE
@ -201,16 +202,10 @@ class Svd_do_intersect_C2
: public Svd_basic_predicates_C2<K>
{
public:
// typedef std::pair<Intersection_type,Intersection_type> result_type;
typedef std::pair<int,int> result_type;
enum
{ FIRST_ENDPOINT = 0, SECOND_ENDPOINT, INTERIOR_POINT,
NO_INTERSECTION, IDENTICAL, SUBSEGMENT
} Intersection_type;
private:
typedef Svd_basic_predicates_C2<K> Base;
typedef Svd_basic_predicates_C2<K> Base;
typedef typename Base::Point_2 Point_2;
typedef typename Base::Segment_2 Segment_2;
@ -222,19 +217,14 @@ private:
typedef typename K::Orientation_2 Orientation_2;
typedef Svd_are_same_points_C2<K> Are_same_points_C2;
typedef Svd_are_same_points_C2<K> Are_same_points_C2;
typedef Svd_are_same_segments_C2<K> Are_same_segments_C2;
private:
bool same_segments(const Site_2& p, const Site_2& q) const
{
CGAL_precondition( p.is_segment() && q.is_segment() );
return
( are_same(p.source_site(), q.source_site()) &&
are_same(p.target_site(), q.target_site()) ) ||
( are_same(p.source_site(), q.target_site()) &&
are_same(p.target_site(), q.source_site()) );
}
Are_same_points_C2 same_points;
Are_same_segments_C2 same_segments;
private:
//------------------------------------------------------------------------
result_type
@ -306,13 +296,13 @@ public:
return std::pair<int,int>(4,4);
}
if ( are_same(p.source_site(), q.source_site()) ) {
if ( same_points(p.source_site(), q.source_site()) ) {
return do_intersect_same_point(p, q, 0, 0);
} if ( are_same(p.source_site(), q.target_site()) ) {
} if ( same_points(p.source_site(), q.target_site()) ) {
return do_intersect_same_point(p, q, 0, 1);
} else if ( are_same(p.target_site(), q.source_site()) ) {
} else if ( same_points(p.target_site(), q.source_site()) ) {
return do_intersect_same_point(p, q, 1, 0);
} else if ( are_same(p.target_site(), q.target_site()) ) {
} else if ( same_points(p.target_site(), q.target_site()) ) {
return do_intersect_same_point(p, q, 1, 1);
}
@ -327,16 +317,7 @@ public:
s2.target().x(), s2.target().y() );
return res;
// Intersection_type it1 = res.first;
// Intersection_type it2 = res.second;
// return result_type(it1, it2);
}
private:
Are_same_points_C2 are_same;
};
//---------------------------------------------------------------------

View File

@ -26,6 +26,7 @@
#include <CGAL/predicates/Svd_basic_predicates_C2.h>
#include <CGAL/predicates/Segment_Voronoi_diagram_vertex_2.h>
#include <CGAL/predicates/Svd_are_same_points_C2.h>
#include <CGAL/predicates/Svd_are_same_segments_C2.h>
CGAL_BEGIN_NAMESPACE
@ -52,19 +53,11 @@ public:
private:
typedef Svd_are_same_points_C2<K> Are_same_points_2;
typedef Svd_are_same_segments_C2<K> Are_same_segments_2;
private:
Are_same_points_2 are_same;
bool same_segments(const Site_2& p, const Site_2& q) const
{
CGAL_precondition( p.is_segment() && q.is_segment() );
return
( are_same(p.source_site(), q.source_site()) &&
are_same(p.target_site(), q.target_site()) ) ||
( are_same(p.source_site(), q.target_site()) &&
are_same(p.target_site(), q.source_site()) );
}
Are_same_points_2 same_points;
Are_same_segments_2 same_segments;
private:
@ -115,15 +108,15 @@ private:
Oriented_side op, oq;
if ( are_same(sp, t.source_site()) ||
are_same(sp, t.target_site()) ) {
if ( same_points(sp, t.source_site()) ||
same_points(sp, t.target_site()) ) {
op = ON_ORIENTED_BOUNDARY;
} else {
op = oriented_side_of_line(lt, p);
}
if ( are_same(sq, t.source_site()) ||
are_same(sq, t.target_site()) ) {
if ( same_points(sq, t.source_site()) ||
same_points(sq, t.target_site()) ) {
oq = ON_ORIENTED_BOUNDARY;
} else {
oq = oriented_side_of_line(lt, q);
@ -180,8 +173,8 @@ private:
{
CGAL_precondition( p.is_point() && q.is_segment() );
if ( are_same(p, q.source_site()) ||
are_same(p, q.target_site()) ) {
if ( same_points(p, q.source_site()) ||
same_points(p, q.target_site()) ) {
return false;
}
@ -236,8 +229,8 @@ private:
lq = opposite_line(lq);
}
if ( are_same(sp, st.source_site()) ||
are_same(sp, st.target_site()) ) {
if ( same_points(sp, st.source_site()) ||
same_points(sp, st.target_site()) ) {
Line_2 lqperp = compute_perpendicular(lq, p);
@ -254,18 +247,16 @@ private:
if ( !on_different_parabola_arcs ) { return true; }
Site_2 t1;
if ( are_same(sp, st.source_site()) ) {
if ( same_points(sp, st.source_site()) ) {
t1 = st.target_site();
} else {
t1 = st.source_site();
}
// Oriented_side o_p = oriented_side_of_line(lq, p);
Oriented_side o_t1;
if ( are_same(t1, sq.source_site()) ||
are_same(t1, sq.target_site()) ) {
if ( same_points(t1, sq.source_site()) ||
same_points(t1, sq.target_site()) ) {
o_t1 = ON_ORIENTED_BOUNDARY;
} else if ( !t1.is_exact() &&
( same_segments(t1.supporting_site(0),
@ -277,10 +268,6 @@ private:
o_t1 = oriented_side_of_line(lq, t1.point());
}
// CGAL_assertion( o_p == ON_POSITIVE_SIDE );
// if ( (o_p == ON_POSITIVE_SIDE && o_t1 == ON_NEGATIVE_SIDE) ||
// (o_p == ON_NEGATIVE_SIDE && o_t1 == ON_POSITIVE_SIDE) ) {
if ( o_t1 == ON_NEGATIVE_SIDE ) {
return true;
}
@ -451,8 +438,8 @@ private:
{
CGAL_precondition( sp.is_point() && sq.is_segment() && st.is_point() );
if ( are_same(sp, sq.source_site()) ||
are_same(sp, sq.target_site()) ) {
if ( same_points(sp, sq.source_site()) ||
same_points(sp, sq.target_site()) ) {
return false;
}
@ -512,12 +499,9 @@ private:
// first orient lp according to its Voronoi vertices
if ( ( vpqr.is_degenerate_Voronoi_circle() &&
are_same(vpqr.degenerate_point(), p.source_site()) ) ||
same_points(vpqr.degenerate_point(), p.source_site()) ) ||
( vpqr.is_degenerate_Voronoi_circle() &&
are_same(vpqr.degenerate_point(), p.target_site()) ) ) {
// CGAL_assertion
// ( !vqps.is_same_point(p.source(), tag) &&
// !vqps.is_same_point(p.target(), tag) );
same_points(vpqr.degenerate_point(), p.target_site()) ) ) {
if ( vqps.oriented_side(lp) != ON_POSITIVE_SIDE ) {
lp = opposite_line(lp);
}
@ -529,12 +513,9 @@ private:
// then orient lq according to its Voronoi vertices
if ( ( vpqr.is_degenerate_Voronoi_circle() &&
are_same(vpqr.degenerate_point(), q.source_site()) ) ||
same_points(vpqr.degenerate_point(), q.source_site()) ) ||
( vpqr.is_degenerate_Voronoi_circle() &&
are_same(vpqr.degenerate_point(), q.target_site()) ) ) {
// CGAL_assertion
// ( !vqps.is_same_point(q.source(), tag) &&
// !vqps.is_same_point(q.target(), tag) );
same_points(vpqr.degenerate_point(), q.target_site()) ) ) {
if ( vqps.oriented_side(lq) != ON_POSITIVE_SIDE ) {
lq = opposite_line(lq);
}
@ -589,28 +570,6 @@ public:
bool operator()(const Site_2& p, const Site_2& q, const Site_2& r,
const Site_2& s, const Site_2& t, Sign sgn) const
{
#if 0
std::cout << "inside finite edge interior top "
<< "level operator()" << std::endl;
std::cout << "p: " << p << std::endl;
std::cout << "q: " << q << std::endl;
std::cout << "r: " << r << std::endl;
std::cout << "s: " << s << std::endl;
std::cout << "t: " << t << std::endl;
std::cout << "sgn: " << sgn << std::endl;
#endif
#if 0
bool res;
if ( sgn == POSITIVE ) {
res = is_interior_in_conflict_none(p, q, r, s, t, Method_tag());
} else if ( sgn == NEGATIVE ) {
res = is_interior_in_conflict_both(p, q, r, s, t, Method_tag());
} else {
res = is_interior_in_conflict_touch(p, q, r, s, t, Method_tag());
}
#endif
if ( sgn == POSITIVE ) {
return is_interior_in_conflict_none(p, q, r, s, t, Method_tag());
} else if ( sgn == NEGATIVE ) {
@ -637,11 +596,9 @@ public:
}
bool p_is_endpoint =
are_same(p, t.source_site()) || are_same(p, t.target_site());
// (p.point() == t.source() || p.point() == t.target());
same_points(p, t.source_site()) || same_points(p, t.target_site());
bool q_is_endpoint =
are_same(q, t.source_site()) || are_same(q, t.target_site());
// (q.point() == t.source() || q.point() == t.target());
same_points(q, t.source_site()) || same_points(q, t.target_site());
return ( p_is_endpoint && q_is_endpoint );
}
@ -649,39 +606,6 @@ public:
bool operator()(const Site_2& p, const Site_2& q, const Site_2& t,
Sign sgn) const
{
#if 1
std::cout << "inside finite edge interior top "
<< "level operator()" << std::endl;
std::cout << "p: " << p << std::endl;
std::cout << "q: " << q << std::endl;
std::cout << "t: " << t << std::endl;
std::cout << "sgn: " << sgn << std::endl;
#endif
#if 0
// MK::ERROR: NEW STUFF; but not necessary ?
if ( p.is_point() && q.is_point() && t.is_point() ) {
if ( sgn == NEGATIVE ) { return true; }
RT dtpx = p.point().x() - t.point().x();
RT minus_dtpy = -p.point().y() + t.point().y();
RT dtqx = q.point().x() - t.point().x();
RT dtqy = q.point().y() - t.point().y();
Sign s1 = sign_of_determinant2x2(dtpx, minus_dtpy, dtqy, dtqx);
std::cout << "s1: " << int(s1) << std::endl;
CGAL_assertion( s1 != ZERO );
return ( s1 == NEGATIVE );
}
#endif
#if 0
if ( sgn != ZERO ) {
return false;
}
#endif
if ( p.is_segment() || q.is_segment()) {
return false;
}
@ -695,16 +619,14 @@ public:
Sign s1 = sign_of_determinant2x2(dtpx, minus_dtpy, dtqy, dtqx);
std::cout << "s1: " << int(s1) << std::endl;
CGAL_assertion( s1 != ZERO );
return ( s1 == NEGATIVE );
}
bool bp =
are_same(p, t.source_site()) || are_same(p, t.target_site());
same_points(p, t.source_site()) || same_points(p, t.target_site());
bool bq =
are_same(q, t.source_site()) || are_same(q, t.target_site());
same_points(q, t.source_site()) || same_points(q, t.target_site());
return ( bp && bq );

View File

@ -24,6 +24,7 @@
#include <CGAL/predicates/Segment_Voronoi_diagram_vertex_2.h>
#include <CGAL/predicates/Svd_are_same_points_C2.h>
#include <CGAL/predicates/Svd_are_same_segments_C2.h>
CGAL_BEGIN_NAMESPACE
@ -41,21 +42,12 @@ private:
typedef typename K::FT FT;
typedef typename K::RT RT;
typedef Svd_are_same_points_C2<K> Are_same_points_C2;
typedef Svd_are_same_points_C2<K> Are_same_points_C2;
typedef Svd_are_same_segments_C2<K> Are_same_segments_C2;
private:
Are_same_points_C2 are_same;
bool same_segments(const Site_2& p, const Site_2& q) const
{
CGAL_precondition( p.is_segment() && q.is_segment() );
return
( are_same(p.source_site(), q.source_site()) &&
are_same(p.target_site(), q.target_site()) ) ||
( are_same(p.source_site(), q.target_site()) &&
are_same(p.target_site(), q.source_site()) );
}
Are_same_points_C2 same_points;
Are_same_segments_C2 same_segments;
bool is_on_common_support(const Site_2& s1, const Site_2& s2,
const Point_2& p) const
@ -67,15 +59,15 @@ private:
same_segments(s1.supporting_site(0),
s2.supporting_site(1)) ) {
Site_2 support = s1.supporting_site(0);
return ( are_same(support.source_site(), p) ||
are_same(support.target_site(), p) );
return ( same_points(support.source_site(), p) ||
same_points(support.target_site(), p) );
} else if ( same_segments(s1.supporting_site(1),
s2.supporting_site(1)) ||
same_segments(s1.supporting_site(1),
s2.supporting_site(0)) ) {
Site_2 support = s1.supporting_site(1);
return ( are_same(support.source_site(), p) ||
are_same(support.target_site(), p) );
return ( same_points(support.source_site(), p) ||
same_points(support.target_site(), p) );
}
return false;
}
@ -192,10 +184,10 @@ private:
Orientation o;
if ( p.is_point() && q.is_segment() ) {
Point_2 pq = are_same(p, q.source_site()) ? q.target() : q.source();
Point_2 pq = same_points(p, q.source_site()) ? q.target() : q.source();
o = orientation(p.point(), pq, t.point());
} else { // p is a segment and q is a point
Point_2 pp = are_same(q, p.source_site()) ? p.target() : p.source();
Point_2 pp = same_points(q, p.source_site()) ? p.target() : p.source();
o = orientation(pp, q.point(), t.point());
}
return ( o == RIGHT_TURN ) ? NEGATIVE : POSITIVE;
@ -208,13 +200,12 @@ private:
const Site_2& t) const
{
CGAL_precondition( p.is_point() && q.is_point() );
// CGAL_precondition( t.is_segment() );
bool is_p_tsrc = are_same(p, t.source_site());
bool is_p_ttrg = are_same(p, t.target_site());
bool is_p_tsrc = same_points(p, t.source_site());
bool is_p_ttrg = same_points(p, t.target_site());
bool is_q_tsrc = are_same(q, t.source_site());
bool is_q_ttrg = are_same(q, t.target_site());
bool is_q_tsrc = same_points(q, t.source_site());
bool is_q_ttrg = same_points(q, t.target_site());
bool is_p_on_t = is_p_tsrc || is_p_ttrg;
bool is_q_on_t = is_q_tsrc || is_q_ttrg;
@ -257,16 +248,14 @@ private:
const Site_2& t) const
{
CGAL_precondition( p.is_segment() && q.is_point() );
// CGAL_precondition( t.is_segment() );
bool is_q_tsrc = are_same(q, t.source_site());
bool is_q_ttrg = are_same(q, t.target_site());
bool is_q_tsrc = same_points(q, t.source_site());
bool is_q_ttrg = same_points(q, t.target_site());
bool is_q_on_t = is_q_tsrc || is_q_ttrg;
// if ( q == t.source() && q == t.target() ) {
if ( is_q_on_t ) {
Point_2 pp = are_same(q, p.source_site()) ? p.target() : p.source();
Point_2 pp = same_points(q, p.source_site()) ? p.target() : p.source();
Point_2 pt = is_q_tsrc ? t.target() : t.source();
Orientation o = orientation(pp, q.point(), pt);
@ -282,15 +271,14 @@ private:
const Site_2& t) const
{
CGAL_precondition( p.is_point() && q.is_segment() );
// CGAL_precondition( t.is_segment() );
bool is_p_tsrc = are_same(p, t.source_site());
bool is_p_ttrg = are_same(p, t.target_site());
bool is_p_tsrc = same_points(p, t.source_site());
bool is_p_ttrg = same_points(p, t.target_site());
bool is_p_on_t = is_p_tsrc || is_p_ttrg;
if ( is_p_on_t ) {
Point_2 pq = are_same(p, q.source_site()) ? q.target() : q.source();
Point_2 pq = same_points(p, q.source_site()) ? q.target() : q.source();
Point_2 pt = is_p_tsrc ? t.target() : t.source();
Orientation o = orientation(p.point(), pq, pt);
@ -325,25 +313,6 @@ public:
Sign operator()(const Site_2& p, const Site_2& q,
const Site_2& r, const Site_2& t) const
{
#if 0
if ( p.is_point() && q.is_point() &&
r.is_point() && t.is_point() ) {
RT x = p.point().x();
Object o = make_object(x);
Gmpq qx;
if ( assign(qx, o) ) {
std::cout << "+++++++++++++++++++++++++++++++++++++" << std::endl;
std::cout << "inside vertex conflict top "
<< "level operator()" << std::endl;
std::cout << "p: " << p << " exact? " << p.is_exact() << std::endl;
std::cout << "q: " << q << " exact? " << q.is_exact() << std::endl;
std::cout << "r: " << r << " exact? " << r.is_exact() << std::endl;
std::cout << "t: " << t << " exact? " << t.is_exact() << std::endl;
std::cout << "-------------------------------------" << std::endl;
}
}
#endif
Voronoi_vertex_2 v(p, q, r);
return v.incircle(t);
@ -355,55 +324,22 @@ public:
Sign operator()(const Site_2& p, const Site_2& q,
const Site_2& t) const
{
#if 0
if ( p.is_point() && q.is_point() && t.is_point() ) {
RT x = p.point().x();
Object o = make_object(x);
Gmpq qx;
if ( assign(qx, o) ) {
std::cout << "+++++++++++++++++++++++++++++++++++++" << std::endl;
std::cout << "inside vertex conflict top "
<< "level operator()" << std::endl;
std::cout << "p: " << p << " exact? " << p.is_exact() << std::endl;
std::cout << "q: " << q << " exact? " << q.is_exact() << std::endl;
std::cout << "t: " << t << " exact? " << t.is_exact() << std::endl;
std::cout << "-------------------------------------" << std::endl;
}
}
#endif
#if 1
std::cout << "+++++++++++++++++++++++++++++++++++++" << std::endl;
std::cout << "inside vertex conflict top "
<< "level operator()" << std::endl;
std::cout << "p: " << p << " exact? " << p.is_exact() << std::endl;
std::cout << "q: " << q << " exact? " << q.is_exact() << std::endl;
std::cout << "t: " << t << " exact? " << t.is_exact() << std::endl;
#endif
CGAL_assertion( !(p.is_segment() && q.is_segment()) );
if ( p.is_point() && q.is_segment() ) {
// p must be an endpoint of q
CGAL_assertion( are_same(p, q.source_site()) ||
are_same(p, q.target_site()) );
CGAL_assertion( same_points(p, q.source_site()) ||
same_points(p, q.target_site()) );
} else if ( p.is_segment() && q.is_point() ) {
// q must be an endpoint of p
CGAL_assertion( are_same(p.source_site(), q) ||
are_same(p.target_site(), q) );
CGAL_assertion( same_points(p.source_site(), q) ||
same_points(p.target_site(), q) );
}
if ( t.is_point() ) {
#if 1
std::cout << "incircle: " << incircle_p(p, q, t) << std::endl;
std::cout << "-------------------------------------" << std::endl;
#endif
return incircle_p(p, q, t);
}
#if 1
std::cout << "incircle: " << incircle_s(p, q, t) << std::endl;
std::cout << "-------------------------------------" << std::endl;
#endif
// MK::ERROR: do geometric filtering when orientation is called.
return incircle_s(p, q, t);
}

View File

@ -25,64 +25,39 @@
#include <CGAL/predicates/Svd_basic_predicates_C2.h>
#include <CGAL/predicates/Segment_Voronoi_diagram_vertex_2.h>
#include <CGAL/predicates/Svd_are_same_points_C2.h>
#include <CGAL/predicates/Svd_are_same_segments_C2.h>
CGAL_BEGIN_NAMESPACE
//-----------------------------------------------------------------------------
template<class K, class Method_tag>
class Svd_infinite_edge_interior_2
{
public:
typedef typename K::Site_2 Site_2;
typedef typename K::RT RT;
typedef Svd_are_same_points_C2<K> Are_same_points_2;
typedef typename K::Site_2 Site_2;
typedef typename K::RT RT;
typedef Svd_are_same_points_C2<K> Are_same_points_2;
typedef Svd_are_same_segments_C2<K> Are_same_segments_2;
private:
Are_same_points_2 are_same;
bool same_segments(const Site_2& p, const Site_2& q) const
{
CGAL_precondition( p.is_segment() && q.is_segment() );
return
( are_same(p.source_site(), q.source_site()) &&
are_same(p.target_site(), q.target_site()) ) ||
( are_same(p.source_site(), q.target_site()) &&
are_same(p.target_site(), q.source_site()) );
}
Are_same_points_2 same_points;
Are_same_segments_2 same_segments;
public:
bool operator()(const Site_2& q, const Site_2& s, const Site_2& r,
const Site_2& t, Sign sgn) const
{
#if 1
std::cout << "inside infinite edge interior top "
<< "level operator()" << std::endl;
std::cout << "q: " << q << std::endl;
std::cout << "s: " << s << std::endl;
std::cout << "r: " << r << std::endl;
std::cout << "t: " << t << std::endl;
std::cout << "sgn: " << sgn << std::endl;
#endif
if ( t.is_segment() ) {
#if PRED_PRINT
std::cout << false << std::endl;
#endif
return false;
}
#if 1
if ( q.is_segment() ) {
// in this case r and s must be endpoints of q
return ( sgn == NEGATIVE );
}
#endif
if ( s.is_point() && r.is_point() && are_same(s, r) ) {
if ( s.is_point() && r.is_point() && same_points(s, r) ) {
// MK::ERROR: write this code using the compare_x_2 and
// compare_y_2 predicates instead of computing the inner
// product...
@ -95,17 +70,14 @@ public:
CGAL_assertion( sgn1 != ZERO );
#if 1
std::cout << "result: " << (sgn1 == POSITIVE) << std::endl;
#endif
return (sgn1 == POSITIVE);
}
if ( s.is_segment() && r.is_segment() && same_segments(s, r) ) {
CGAL_assertion( are_same(q, s.source_site()) ||
are_same(q, s.target_site()) );
CGAL_assertion( same_points(q, s.source_site()) ||
same_points(q, s.target_site()) );
Site_2 ss;
if ( are_same(q, s.source_site()) ) {
if ( same_points(q, s.source_site()) ) {
ss = s.target_site();
} else {
ss = s.source_site();
@ -122,9 +94,6 @@ public:
CGAL_assertion( sgn1 != ZERO );
#if 1
std::cout << "result: " << (sgn1 == POSITIVE) << std::endl;
#endif
return (sgn1 == POSITIVE);
}

View File

@ -24,7 +24,7 @@
#define CGAL_SVD_IS_DEGENERATE_EDGE_2_H
//#include <CGAL/predicates/Svd_basic_predicates_C2.h>
#include <CGAL/predicates/Segment_Voronoi_diagram_vertex_2.h>
//#include <CGAL/predicates/Segment_Voronoi_diagram_vertex_2.h>
CGAL_BEGIN_NAMESPACE

View File

@ -48,8 +48,6 @@ private:
typedef typename Base::FT FT;
typedef typename Base::RT RT;
typedef typename Base::Homogeneous_point_2 Homogeneous_point_2;
public:
// computes the oriented side of the Voronoi vertex of s1, s2, s3
// wrt the line that is passes through the point p and its direction

View File

@ -23,9 +23,9 @@
#ifndef CGAL_SVD_ORIENTED_SIDE_OF_BISECTOR_C2_H
#define CGAL_SVD_ORIENTED_SIDE_OF_BISECTOR_C2_H
#include <CGAL/Cartesian/distance_predicates_2.h>
#include <CGAL/predicates/Svd_basic_predicates_C2.h>
#include <CGAL/predicates/Svd_are_same_points_C2.h>
#include <CGAL/predicates/Svd_are_same_segments_C2.h>
CGAL_BEGIN_NAMESPACE
@ -38,11 +38,17 @@ class Svd_oriented_side_of_bisector_C2
{
private:
typedef Svd_basic_predicates_C2<K> Base;
typedef Svd_are_same_points_C2<K> Are_same_points_C2;
typedef typename Base::Line_2 Line_2;
typedef typename Base::RT RT;
typedef typename Base::FT FT;
typedef Svd_are_same_points_C2<K> Are_same_points_C2;
typedef Svd_are_same_segments_C2<K> Are_same_segments_C2;
private:
Are_same_points_C2 same_points;
Are_same_segments_C2 same_segments;
public:
typedef typename Base::Site_2 Site_2;
typedef typename Base::Point_2 Point_2;
@ -51,27 +57,17 @@ public:
typedef Oriented_side result_type;
private:
bool same_segments(const Site_2& s1, const Site_2& s2) const
{
CGAL_precondition( s1.is_segment() && s2.is_segment() );
return
( are_same(s1.source_site(), s2.source_site()) &&
are_same(s1.target_site(), s2.target_site()) ) ||
( are_same(s1.source_site(), s2.target_site()) &&
are_same(s1.target_site(), s2.source_site()) );
}
bool is_endpoint(const Site_2& p, const Site_2& s) const
{
CGAL_precondition( p.is_point() && s.is_segment() );
return
are_same(p, s.source_site()) || are_same(p, s.target_site());
same_points(p, s.source_site()) || same_points(p, s.target_site());
}
bool is_degenerate(const Site_2& s) const
{
CGAL_precondition( s.is_segment() );
return are_same( s.source_site(), s.target_site() );
return same_points( s.source_site(), s.target_site() );
}
//-----------------------------------------------------------------
@ -81,10 +77,10 @@ private:
const Site_2& q) const
{
CGAL_precondition( p1.is_point() && p2.is_point() );
CGAL_precondition( !are_same(p1,p2) );
CGAL_precondition( !same_points(p1,p2) );
if ( are_same(q, p1) ) { return SMALLER; }
if ( are_same(q, p2) ) { return LARGER; }
if ( same_points(q, p1) ) { return SMALLER; }
if ( same_points(q, p2) ) { return LARGER; }
return
compare_distance_to_point(q.point(), p1.point(), p2.point());
@ -99,13 +95,13 @@ private:
CGAL_precondition( s.is_segment() && p.is_point() );
CGAL_precondition( !is_degenerate(s) );
if ( are_same(q, p) ) { return LARGER; }
if ( are_same(q, s.source_site()) ) { return SMALLER; }
if ( are_same(q, s.target_site()) ) { return SMALLER; }
if ( same_points(q, p) ) { return LARGER; }
if ( same_points(q, s.source_site()) ) { return SMALLER; }
if ( same_points(q, s.target_site()) ) { return SMALLER; }
bool is_src = are_same(p, s.source_site());
bool is_trg = are_same(p, s.target_site());
bool is_src = same_points(p, s.source_site());
bool is_trg = same_points(p, s.target_site());
if ( is_src || is_trg ) {
Line_2 ls = compute_supporting_line(s.supporting_segment());
@ -226,13 +222,13 @@ private:
if ( idx1 == -1 ) {
RT d2_s1 = compute_squared_distance(qq, ssrc1);
if ( idx2 == -1 ) {
if ( are_same(s1.source_site(), s2.source_site()) ) {
if ( same_points(s1.source_site(), s2.source_site()) ) {
return EQUAL;
}
RT d2_s2 = compute_squared_distance(qq, ssrc2);
return CGAL::compare(d2_s1, d2_s2);
} else if ( idx2 == 1 ) {
if ( are_same(s1.source_site(), s2.target_site()) ) {
if ( same_points(s1.source_site(), s2.target_site()) ) {
return EQUAL;
}
RT d2_s2 = compute_squared_distance(qq, strg2);
@ -244,13 +240,13 @@ private:
} else if ( idx1 == 1 ) {
RT d2_s1 = compute_squared_distance(qq, strg1);
if ( idx2 == -1 ) {
if ( are_same(s1.target_site(), s2.source_site()) ) {
if ( same_points(s1.target_site(), s2.source_site()) ) {
return EQUAL;
}
RT d2_s2 = compute_squared_distance(qq, ssrc2);
return CGAL::compare(d2_s1, d2_s2);
} else if ( idx2 == 1 ) {
if ( are_same(s1.target_site(), s2.target_site()) ) {
if ( same_points(s1.target_site(), s2.target_site()) ) {
return EQUAL;
}
RT d2_s2 = compute_squared_distance(qq, strg2);
@ -304,27 +300,9 @@ public:
operator()(const Site_2& t1, const Site_2& t2,
const Site_2& q) const
{
#if 0
RT x = q.point().x();
Object o = make_object(x);
Gmpq qx;
if ( assign(qx, o) ) {
std::cout << "+++++++++++++++++++++++++++++++++++++" << std::endl;
std::cout << "inside oriented side of bisector top "
<< "level operator()" << std::endl;
std::cout << "t1: " << t1 << std::endl;
std::cout << "t2: " << t2 << std::endl;
std::cout << "q: " << q << std::endl;
std::cout << "-------------------------------------" << std::endl;
}
#endif
CGAL_precondition( q.is_point() );
return compare_distances(t1, t2, q);
}
private:
Are_same_points_C2 are_same;
};