Supporting files (tested with ConiX)

This commit is contained in:
Pavel Emeliyanenko 2007-08-15 13:10:35 +00:00
parent bbc1648717
commit eefb69ff8d
5 changed files with 758 additions and 897 deletions

View File

@ -17,10 +17,6 @@
#include <CGAL/basic.h>
#include <CGAL/Handle_with_policy.h>
#include <SoX/basic.h>
//#include <CGAL/algorithm.h>
#include <SoX/GAPS/types.h>
CGAL_BEGIN_NAMESPACE
template < class AlgebraicCurveKernel_2, class Rep_ >
@ -49,12 +45,12 @@ public:
{ }
// standard constructor
Curve_analysis_2_rep(const Curve_2& curve) : curve_(curve)
Curve_analysis_2_rep(const Curve_2& curve) : _m_curve(curve)
{ }
// data
// temporarily this implementation uses underlying Curve_2 from SweepX
mutable Curve_2 curve_;
mutable Curve_2 _m_curve;
// befriending the handle
friend class Curve_analysis_2<Algebraic_curve_kernel_2, Self>;
@ -97,44 +93,52 @@ public:
typedef Curve_analysis_2<Algebraic_curve_kernel_2, Rep> Self;
//! type of a vertical line
typedef CGALi::Curve_vertical_line_1<Self>
Curve_vertical_line_1;
typedef CGALi::Curve_vertical_line_1<Self> Curve_vertical_line_1;
//! type of underlying Event1_info structure
typedef typename Curve_2::Event1_info Event1_info;
//! the handle superclass
typedef ::CGAL::Handle_with_policy<Rep> Base;
//!@}
public:
//!\name Constructors
//!@{
//! \brief default constructor
Curve_analysis_2() : Base(Rep())
{ }
Curve_analysis_2() :
Base(Rep()) {
}
/*!\brief
* copy constructor
*/
Curve_analysis_2(const Self& p) : Base(static_cast<const Base&>(p))
{ }
Curve_analysis_2(const Self& p) :
Base(static_cast<const Base&>(p)) {
}
//! \brief constructs a curve analysis from a given \c Curve_2 object
Curve_analysis_2(const Curve_2& c) : Base(Rep(c))
{ }
Curve_analysis_2(const Curve_2& c) :
Base(Rep(c)) {
}
/*!\brief
* constructsa curve analysis from a given represenation
*/
Curve_analysis_2(Rep rep) : Base(rep)
{ }
Curve_analysis_2(Rep rep) :
Base(rep) {
}
//!@}
public:
//!\name Access functions
//!@{
//! \brief returns the defining polynomial of the analysis
Curve_2 get_polynomial_2() const
{
return this->ptr()->curve_;
return this->ptr()->_m_curve;
}
//! \brief alias for \c get_polynomial_2()
@ -146,7 +150,7 @@ public:
//! \brief returns number of vertical lines that encode an event
int number_of_vertical_lines_with_event() const
{
return this->ptr()->curve_.num_events();
return this->ptr()->_m_curve.num_events();
}
//! \brief returns an instance of \c CurveVerticalLine_1 at the i-th
@ -156,10 +160,7 @@ public:
Curve_vertical_line_1 vertical_line_at_event(int i) const
{
CGAL_precondition(i >= 0&&i < number_of_vertical_lines_with_event());
// ::CGAL::set_pretty_mode(std::cout);
// std::cout << "evt info, i = " << i << ": " <<
// this->ptr()->curve_.event_info(i) << std::endl;
return Curve_vertical_line_1(this->ptr()->curve_.event_info(i),
return Curve_vertical_line_1(this->ptr()->_m_curve.event_info(i),
*this, i);
}
@ -170,13 +171,13 @@ public:
Curve_vertical_line_1 vertical_line_of_interval(int i) const
{
CGAL_precondition(i >= 0&&i <= number_of_vertical_lines_with_event());
int n_arcs = this->ptr()->curve_.arcs_over_interval(i);
int n_arcs = this->ptr()->_m_curve.arcs_over_interval(i);
// # of arcs to the left and to the right is the same over an interval
typename Curve_vertical_line_1::Event1_info ei(X_coordinate_1(
this->ptr()->curve_.boundary_value_in_interval(i)),
n_arcs, n_arcs);
Event1_info ei(X_coordinate_1(this->ptr()->_m_curve.
boundary_value_in_interval(i)), n_arcs, n_arcs);
// initialize n continuous arcs
std::vector<SoX::Curve_arc_2 > dummy_arcs(n_arcs);
typename Event1_info::Arc_container dummy_arcs(n_arcs);
ei.set_arcs(dummy_arcs);
ei.fix();
return Curve_vertical_line_1(ei, *this, i);
@ -197,7 +198,7 @@ public:
// CGAL_precondition(x is finite ??);
int i;
bool is_evt;
this->ptr()->curve_.x_to_index(x, i, is_evt);
this->ptr()->_m_curve.x_to_index(x, i, is_evt);
if(is_evt) {
if(perturb == CGAL::ZERO)
return vertical_line_at_event(i);
@ -215,19 +216,20 @@ public:
// CGAL_precondition(x is finite ??);
int i;
bool is_evt;
this->ptr()->curve_.x_to_index(x, i, is_evt);
this->ptr()->_m_curve.x_to_index(x, i, is_evt);
if(is_evt)
return vertical_line_at_event(i);
// otherwise construct Event1_info at certain x over the ith interval
int n_arcs = this->ptr()->curve_.arcs_over_interval(i);
typename Curve_vertical_line_1::Event1_info ei(x, n_arcs, n_arcs);
int n_arcs = this->ptr()->_m_curve.arcs_over_interval(i);
Event1_info ei(x, n_arcs, n_arcs);
// initialize n continuous arcs
std::vector<SoX::Curve_arc_2 > dummy_arcs(n_arcs);
typename Event1_info::Arc_container dummy_arcs(n_arcs);
ei.set_arcs(dummy_arcs);
ei.fix();
return Curve_vertical_line_1(ei, *this, i);
}
//!@}
}; // class Curve_analysis_2
} // namespace CGALi

View File

@ -15,11 +15,6 @@
#define CGAL_ALGEBRAIC_CURVE_KERNEL_CURVE_PAIR_ANALYSIS_2_H
#include <CGAL/basic.h>
#include <CGAL/Handle_with_policy.h>
#include <SoX/basic.h>
//#include <CGAL/algorithm.h>
#include <SoX/GAPS/types.h>
CGAL_BEGIN_NAMESPACE
@ -53,21 +48,21 @@ public:
// temporary constructor: directly from curve pair
Curve_pair_analysis_2_rep(const Curve_pair_2& curve_pair) :
ca1_(curve_pair.curve1()), ca2_(curve_pair.curve2()),
curve_pair_(curve_pair)
_m_ca1(curve_pair.curve1()), _m_ca2(curve_pair.curve2()),
_m_curve_pair(curve_pair)
{ }
// constructs from two curve analysis
Curve_pair_analysis_2_rep(const Curve_analysis_2& ca1,
const Curve_analysis_2& ca2) : ca1_(ca1), ca2_(ca2),
curve_pair_(ca1.get_polynomial_2(), ca2.get_polynomial_2())
const Curve_analysis_2& ca2) : _m_ca1(ca1), _m_ca2(ca2),
_m_curve_pair(ca1.get_polynomial_2(), ca2.get_polynomial_2())
{ }
// data
mutable Curve_analysis_2 ca1_, ca2_;
mutable Curve_analysis_2 _m_ca1, _m_ca2;
// temporarily this implementation uses underlying Curve_pair_2 from SweepX
mutable Curve_pair_2 curve_pair_;
mutable Curve_pair_2 _m_curve_pair;
// befriending the handle
friend class Curve_pair_analysis_2<Algebraic_curve_kernel_2, Self>;
@ -124,38 +119,44 @@ public:
typedef ::CGAL::Handle_with_policy<Rep> Base;
//!@}
public:
//!\name Constructors
//!@{
//! \brief default constructor
Curve_pair_analysis_2() : Base(Rep())
{ }
Curve_pair_analysis_2() :
Base(Rep()) {
}
/*!\brief
* copy constructor
*/
Curve_pair_analysis_2(const Self& p) : Base(static_cast<const Base&>(p))
{ }
Curve_pair_analysis_2(const Self& p) :
Base(static_cast<const Base&>(p)) {
}
//! constructs a curve pair analysis defined by analysis
//! given by \c ca1_ and \c ca2_. The polynomials defining the analysis
//! given by \c _m_ca1 and \c _m_ca2. The polynomials defining the analysis
//! must be squarefree and coprime.
Curve_pair_analysis_2(const Curve_analysis_2& ca1_,
const Curve_analysis_2& ca2_) : Base(Rep(ca1_, ca2_))
{ }
Curve_pair_analysis_2(const Curve_analysis_2& ca1,
const Curve_analysis_2& ca2) :
Base(Rep(ca1, ca2)) {
}
// temporary constructor to construct directly from curve pair
Curve_pair_analysis_2(const Curve_pair_2& curve_pair_) :
Base(Rep(curve_pair_))
{ }
Curve_pair_analysis_2(const Curve_pair_2& curve_pair) :
Base(Rep(curve_pair)) {
}
/*!\brief
* constructs a curve pair analysis from a given represenation
*/
Curve_pair_analysis_2(Rep rep) : Base(rep)
{ }
Curve_pair_analysis_2(Rep rep) :
Base(rep) {
}
//!@}
public:
//!\name Access functions
//!@{
@ -163,14 +164,14 @@ public:
Curve_analysis_2 get_curve_analysis(bool c) const
{
if(c == 0)
return this->ptr()->ca1_;
return this->ptr()->ca2_;
return this->ptr()->_m_ca1;
return this->ptr()->_m_ca2;
}
//! \brief returns number of vertical lines that encode an event
int number_of_vertical_lines_with_event() const
{
return this->ptr()->curve_pair_.num_events();
return this->ptr()->_m_curve_pair.num_events();
}
//! \brief given the i-th event of the curve pair this method returns the
@ -181,7 +182,8 @@ public:
int event_of_curve_analysis(int i, bool c) const
{
CGAL_precondition(i >= 0&&i < number_of_vertical_lines_with_event());
SoX::Index_triple triple = this->ptr()->curve_pair_.event_indices(i);
SoX::Index_triple triple =
this->ptr()->_m_curve_pair.event_indices(i);
return (c == 0 ? triple.ffy : triple.ggy);
}
@ -192,7 +194,7 @@ public:
Curve_pair_vertical_line_1 vertical_line_at_event(int i) const
{
CGAL_precondition(i >= 0&&i < number_of_vertical_lines_with_event());
return this->ptr()->curve_pair_.slice_at_event(i);
return this->ptr()->_m_curve_pair.slice_at_event(i);
}
//! \brief returns an instance of CurvePairVerticalLine_1 of the i-th
@ -202,14 +204,14 @@ public:
Curve_pair_vertical_line_1 vertical_line_of_interval(int i) const
{
CGAL_precondition(i >= 0&&i <= number_of_vertical_lines_with_event());
return this->ptr()->curve_pair_.slice_at_interval(i);
return this->ptr()->_m_curve_pair.slice_at_interval(i);
}
//! \brief returns vertical_line_at_event(i), if x hits i-th event,
//! otherwise vertical_line_of_interval(i), where i is the id of the
//! interval \c x lies in.
//!
//! If \c pertub is \c CGAL::NEGATIVE (CGAL::POSITIVE) and x states an
//! If \c pertub is \c CGAL::NEGATIVE (\c CGAL::POSITIVE) and x states an
//! event, then \c vertical_line_of_interval(i)
//! (\c vertical_line_of_interval(i+1)) is returned.
//!
@ -220,7 +222,7 @@ public:
// CGAL_precondition(x is finite ??);
int i;
bool is_evt;
this->ptr()->curve_pair_.x_to_index(x, i, is_evt);
this->ptr()->_m_curve_pair.x_to_index(x, i, is_evt);
if(is_evt) {
if(perturb == CGAL::ZERO)
return vertical_line_at_event(i);
@ -239,6 +241,7 @@ public:
return vertical_line_for_x(x);
}
//!@}
}; // class Curve_pair_analysis_2
} // namespace CGALi

View File

@ -17,10 +17,6 @@
#include <CGAL/basic.h>
#include <CGAL/Handle_with_policy.h>
#include <SoX/basic.h>
//#include <CGAL/algorithm.h>
#include <SoX/GAPS/types.h>
CGAL_BEGIN_NAMESPACE
namespace CGALi {
@ -63,12 +59,12 @@ public:
// standard constructor
Curve_pair_vertical_line_1_rep(const Event2_slice& event_slice) :
event_slice_(event_slice)
_m_event_slice(event_slice)
{ }
// data
// underlying Event2_slice object (temporary)
mutable Event2_slice event_slice_;
mutable Event2_slice _m_event_slice;
// befriending the handle
friend class Curve_pair_vertical_line_1<Curve_pair_analysis_2, Self>;
@ -124,27 +120,30 @@ public:
/*!\brief
* Default constructor
*/
Curve_pair_vertical_line_1() : Base(Rep())
{ }
Curve_pair_vertical_line_1() :
Base(Rep()) {
}
/*!\brief
* copy constructor
*/
Curve_pair_vertical_line_1(const Self& p) :
Base(static_cast<const Base&>(p))
{ }
Base(static_cast<const Base&>(p)) {
}
/*!\brief
* Constructs a new instance from \c Event2_slice object
*/
Curve_pair_vertical_line_1(const Event2_slice& slice) : Base(Rep(slice))
{ }
Curve_pair_vertical_line_1(const Event2_slice& slice) :
Base(Rep(slice)) {
}
/*!\brief
* constructs from a given represenation
*/
Curve_pair_vertical_line_1(Rep rep) : Base(rep)
{ }
Curve_pair_vertical_line_1(Rep rep) :
Base(rep) {
}
//!@}
public:
@ -156,17 +155,17 @@ public:
// representation
bool is_identical(const Self& line) const
{
return this->ptr()->event_slice_.is_identical(line.get_slice());
return this->ptr()->_m_event_slice.is_identical(line.get_slice());
}
//! \brief returns the x-coordinate of the vertical line (always a finite
//! value).
X_coordinate_1 x() const
{
int id = this->ptr()->event_slice_.id();
int id = this->ptr()->_m_event_slice.id();
if(is_event())
return this->ptr()->event_slice_.curve_pair().event_x(id);
return X_coordinate_1(this->ptr()->event_slice_.curve_pair().
return this->ptr()->_m_event_slice.curve_pair().event_x(id);
return X_coordinate_1(this->ptr()->_m_event_slice.curve_pair().
boundary_value_in_interval(id));
}
@ -175,7 +174,7 @@ public:
//! line component of the curve at the given x-coordinate.
int number_of_events() const
{
return (this->ptr()->event_slice_.num_arcs());
return (this->ptr()->_m_event_slice.num_arcs());
}
//! \brief returns the y-position of the k-th event of the c-th (0 or 1)
@ -183,11 +182,11 @@ public:
//!
//! Note that each event is formed by the first, the second, or both curves
//!
//! \pre 0 <= k < number of arc defined for the c-th curve at \c x()
//! \pre 0 <= k < "number of arcs defined for curve[c] at x()"
int get_event_of_curve(int k, bool c) const
{
typename Event2_slice::Int_container ic =
this->ptr()->event_slice_.arcno_to_pos
this->ptr()->_m_event_slice.arcno_to_pos
((c == 0 ? SoX::CURVE1 : SoX::CURVE2));
CGAL_precondition(0 <= k && k < static_cast<int>(ic.size()));
return (ic[k]);
@ -203,7 +202,7 @@ public:
CGAL_precondition(0 <= j && j < number_of_events());
CGAL_precondition(is_event());
const typename Event2_slice::Arc_at_event_2& arc =
this->ptr()->event_slice_.arc_at_event(j);
this->ptr()->_m_event_slice.arc_at_event(j);
CGAL_precondition(arc.first == SoX::CURVE_BOTH);
return arc.second;
}
@ -220,7 +219,7 @@ public:
Arc_vector;
Arc_vector res(2); // maximum two elements
typename Arc_vector::iterator end =
this->ptr()->event_slice_.pos_to_arc(j, res.begin()), it;
this->ptr()->_m_event_slice.pos_to_arc(j, res.begin()), it;
int idx[2] = {-1, -1};
it = res.begin();
idx[((*it).first == SoX::CURVE1 ? 0 : 1)] = (*it).second;
@ -233,26 +232,23 @@ public:
//! intersection of both curves.
bool is_event() const
{
return this->ptr()->event_slice_.is_event();
return this->ptr()->_m_event_slice.is_event();
}
//! \brief returns true if there is an intersection of both curves.
// is_intersection means that at this x() there is an intersection
// of both curves
bool is_intersection() const
{
CGAL_precondition(is_event());
return this->ptr()->event_slice_.is_intersection();
return this->ptr()->_m_event_slice.is_intersection();
}
// temporary access function (for testing)
Event2_slice get_slice() const
{
return this->ptr()->event_slice_;
return this->ptr()->_m_event_slice;
}
friend std::ostream& operator << <>(std::ostream&, const Self&);
//!@}
}; // class Curve_pair_vertical_line_1
template <class CurvePairAnalysis_2, class Rep>

View File

@ -17,10 +17,6 @@
#include <CGAL/basic.h>
#include <CGAL/Handle_with_policy.h>
#include <SoX/basic.h>
//#include <CGAL/algorithm.h>
#include <SoX/GAPS/types.h>
CGAL_BEGIN_NAMESPACE
namespace CGALi {
@ -61,17 +57,18 @@ public:
// standard constructor
Curve_vertical_line_1_rep(const Event1_info& info,
const Curve_analysis_2& ca_2, int index) :
event_info_(info), ca_2_(ca_2), index_(index)
_m_event_info(info), _m_ca_2(ca_2), _m_index(index)
{ }
// data
// temporary added underlying Event1_info object
mutable Event1_info event_info_;
mutable Event1_info _m_event_info;
mutable Curve_analysis_2 ca_2_; // supporting curve analysis
mutable Curve_analysis_2 _m_ca_2; // supporting curve analysis
mutable int index_; // this vertical line id (# of event or # of interval
// depending on whether or not this vertical line encodes an event
mutable int _m_index; // this vertical line id (# of event or # of
// intervaldepending on whether or not this vertical line encodes
// an event
// befriending the handle
friend class Curve_vertical_line_1<Curve_analysis_2, Self>;
@ -129,15 +126,16 @@ public:
/*!\brief
* Default constructor
*/
Curve_vertical_line_1() : Base(Rep())
{ }
Curve_vertical_line_1() :
Base(Rep()) {
}
/*!\brief
* copy constructor
*/
Curve_vertical_line_1(const Self& p) :
Base(static_cast<const Base&>(p))
{ }
Base(static_cast<const Base&>(p)) {
}
/*!\brief
* Constructs a new instance from \c Event1_info object, supporting
@ -148,55 +146,49 @@ public:
*/
Curve_vertical_line_1(const Event1_info& info,
const Curve_analysis_2& ca_2, int index) :
Base(Rep(info, ca_2, index))
{
Base(Rep(info, ca_2, index)) {
CGAL_precondition(id >= 0 && index <
this->ptr()->ca_2_.
this->ptr()->_m_ca_2.
number_of_vertical_lines_with_event() + (is_event()? 0: 1));
}
/*!\brief
* constructs from a given represenation
*/
Curve_vertical_line_1(Rep rep) : Base(rep)
{ }
Curve_vertical_line_1(Rep rep) :
Base(rep) {
}
public:
//!@}
public:
//!\name access functions
//!@{
// overriden member function while the class doesn't have it's own
// representation
// bool is_identical(const Self& line)
// {
// return this->ptr()->event_info_.is_identical(line.get_info());
// }
//
//! \brief returns the x-coordinate of the vertical line (always a finite
//! value).
X_coordinate_1 x() const
{
return this->ptr()->event_info_.x();
return this->ptr()->_m_event_info.x();
}
//! \brief returns this vertical line supporting curve analysis
Curve_analysis_2 get_curve_analysis_2() const
{
return this->ptr()->ca_2_;
return this->ptr()->_m_ca_2;
}
//! \brief returns this vertical line index (event or interval index)
int get_index() const
{
return this->ptr()->index_;
return this->ptr()->_m_index;
}
//! \brief returns true in case the given curve contains the vertical line
//! as a component
bool covers_line() const
{
return this->ptr()->event_info_.has_vertical_line();
return this->ptr()->_m_event_info.has_vertical_line();
}
//! \brief returns number of distinct and finite intersections of a curve
@ -204,7 +196,7 @@ public:
//! component of the curve at the given x-coordinate.
int number_of_events() const
{
return (this->ptr()->event_info_.num_arcs());
return (this->ptr()->_m_event_info.num_arcs());
}
//!\brief returns an object of type \c Xy_coordinate_2 for the j-th event
@ -216,7 +208,7 @@ public:
// how to get the pointer to the curve ?
// we have to store such a pointer for vertical line
return Xy_coordinate_2(x(),
this->ptr()->ca_2_.get_polynomial_2(), j);
this->ptr()->_m_ca_2.get_polynomial_2(), j);
}
//!\brief returns the number of branches of the curve connected to j-th
@ -229,8 +221,8 @@ public:
{
CGAL_precondition(0 <= j&&j < number_of_events());
return std::make_pair(
this->ptr()->event_info_.num_arcs_left(j),
this->ptr()->event_info_.num_arcs_right(j));
this->ptr()->_m_event_info.num_arcs_left(j),
this->ptr()->_m_event_info.num_arcs_right(j));
}
//!\brief returns the number of vertical asymptotes at x of the curve
@ -240,7 +232,7 @@ public:
get_number_of_branches_approaching_minus_infinity() const
{
int left, right, dummy;
this->ptr()->event_info_.num_arcs_approaching_vertical_asymptote(
this->ptr()->_m_event_info.num_arcs_approaching_vertical_asymptote(
left, right, dummy, dummy);
return std::make_pair(left, right);
}
@ -252,7 +244,7 @@ public:
get_number_of_branches_approaching_plus_infinity() const
{
int left, right, dummy;
this->ptr()->event_info_.num_arcs_approaching_vertical_asymptote(
this->ptr()->_m_event_info.num_arcs_approaching_vertical_asymptote(
dummy, dummy, left, right);
return std::make_pair(left, right);
}
@ -261,15 +253,16 @@ public:
//! has intersection with f_y at \c x
bool is_event() const
{
return this->ptr()->event_info_.is_event();
return this->ptr()->_m_event_info.is_event();
}
// temporary access function (for testing)
Event1_info get_info() const
{
return this->ptr()->event_info_;
return this->ptr()->_m_event_info;
}
//!@}
}; // class Curve_vertical_line_1
template <class CurveAnalysis_2, class Rep>

View File

@ -43,23 +43,23 @@ public:
// constructors
public:
// default constructor ()
Xy_coordinate_2_rep() : arcno_(-1)
Xy_coordinate_2_rep() : _m_arcno(-1)
{ }
// standard constructor
Xy_coordinate_2_rep(const X_coordinate_1& x, const Curve_2& curve,
int arcno) : x_(x), curve_(curve), arcno_(arcno)
int arcno) : _m_x(x), _m_curve(curve), _m_arcno(arcno)
{ }
// data
// x-coordinate
X_coordinate_1 x_;
X_coordinate_1 _m_x;
// supporting curve
mutable Curve_2 curve_;
mutable Curve_2 _m_curve;
// arc number on curve
mutable int arcno_;
mutable int _m_arcno;
// befriending the handle
friend class Xy_coordinate_2<Algebraic_curve_kernel_2, Self>;
@ -77,6 +77,8 @@ template <class AlgebraicCurveKernel_2,
class Xy_coordinate_2 : public ::CGAL::Handle_with_policy< Rep_ >
{
public:
//! \name public typedefs
//!@{
//! this instance's first template parameter
typedef AlgebraicCurveKernel_2 Algebraic_curve_kernel_2;
@ -119,40 +121,17 @@ public:
//! the handle superclass
typedef ::CGAL::Handle_with_policy< Rep > Base;
public:
// Rebind
/*!\brief
* An auxiliary structure for rebinding the point with a new rep
*/
template < typename NewRep >
class Rebind_curve_point_2
{
public:
typedef CGALi::Xy_coordinate_2<Algebraic_curve_kernel_2, NewRep>
Other;
/*!\brief
* constructs a point of type \c Other from the point \c pt
* of type \c Self.
*
* All known items of the base class rep will be copied.
*/
Other operator()(const Self& pt) {
NewRep newrep;
newrep.x_ = pt.ptr()->x_;
newrep.curve_ = pt.ptr()->curve_;
newrep.arcno_ = pt.ptr()->arcno_;
return Other(newrep);
}
};
//!@}
private:
//! \name private methods
//!@{
/*!\brief
* Simplifies the representation of two points whose supporting curves
* share a common part.
*/
inline
static bool simplify(const Xy_coordinate_2& p, const Xy_coordinate_2& q)
static bool _simplify(const Xy_coordinate_2& p, const Xy_coordinate_2& q)
{
std::vector<Curve_2> parts_of_f, parts_of_g, common;
Algebraic_curve_kernel_2 ak_2;
@ -160,24 +139,23 @@ private:
if(ak_2.decompose_2_object()(p.curve(), q.curve(),
std::back_inserter(parts_of_f), std::back_inserter(parts_of_g),
std::back_inserter(common))) {
CGAL_assertion(static_cast<int>(parts_of_f.size()) == 2 ||
static_cast<int>(parts_of_g.size()) == 2);
CGAL_assertion((parts_of_f.size() == 1 ||
parts_of_g.size() == 1) && common.size() == 1);
// ATTENTION: here the cache must be used !!
if (static_cast< int >(parts_of_f.size()) == 2) {
if(parts_of_f.size() == 1) {
p.simplify_by(Curve_pair_analysis_2(
Curve_pair_2(parts_of_f[0], parts_of_f[1])));
} // else nothing to replace
if (static_cast< int >(parts_of_g.size()) == 2) {
Curve_pair_2(parts_of_f[0], common[0])));
}
if(parts_of_g.size() == 1) {
q.simplify_by(Curve_pair_analysis_2(
Curve_pair_2(parts_of_g[0], parts_of_g[1])));
} // else nothing to replace
Curve_pair_2(parts_of_g[0], common[0])));
}
return true;
}
return false;
}
//!@}
public:
//!\name Constructors
//!@{
@ -188,27 +166,28 @@ public:
* A default-constructed point supports no operation other than
* having \c curve().degree() return \c -1.
*/
Xy_coordinate_2() : Base(Rep())
{ }
Xy_coordinate_2() :
Base(Rep()) {
}
/*!\brief
* copy constructor
*/
Xy_coordinate_2(const Self& p) : Base(static_cast<const Base&>(p))
{ }
Xy_coordinate_2(const Self& p) :
Base(static_cast<const Base&>(p)) {
}
// from outside Curve_analysis_2 you must not directly use the methods
// of Curve_2 class - only through available Curve_analysis_2 interface
/*!\brief
* Point at \c x, on \c curve with \c arcno. Finite points on vertical arcs
* are also constructed in this way
*
* \pre y-coordinate of this point must be finite
*/
// from outside Curve_analysis_2 you must not directly use the methods
// of Curve_2 class - only through available Curve_analysis_2 interface
Xy_coordinate_2(const X_coordinate_1& x, const Curve_2& curve, int arcno) :
Base(Rep(x, curve, arcno))
{
Base(Rep(x, curve, arcno)) {
CGAL_precondition(arcno >= 0);
CGAL_precondition_code(
int i = -1;
@ -222,24 +201,11 @@ public:
/*!\brief
* constructs a point from a given represenation
*/
Xy_coordinate_2(Rep rep) : Base(rep)
{ }
//!@}
public:
//!\name Destructors
//!@{
/*!\brief
* Empty desctructor
*/
virtual ~Xy_coordinate_2() {
// empty
Xy_coordinate_2(Rep rep) :
Base(rep) {
}
//!@}
public:
//!\name Access functions
//!@{
@ -248,14 +214,14 @@ public:
* x-coordinate of the point
*/
X_coordinate_1 x() const {
return this->ptr()->x_;
return this->ptr()->_m_x;
}
/*!\brief
* supporting curve of the point
*/
Curve_2 curve() const {
return this->ptr()->curve_;
return this->ptr()->_m_curve;
}
/*!\brief
@ -263,107 +229,22 @@ public:
*
*/
int arcno() const {
return this->ptr()->arcno_;
return this->ptr()->_m_arcno;
}
//!@}
//!\name Traits modifiers
//!@{
protected:
/*!\brief
* test wether comparison of y_order of two covertical points is known
* in advance
*/
inline
#ifndef SoX_GAPS_NO_VIRTUAL_DISPATCH
virtual
#endif
bool knows_y_order(const Self& p) const {
//std::cout << "ACP: knows_y_order" << std::endl;
return false;
}
#ifndef SoX_GAPS_NO_VIRTUAL_DISPATCH
/*!\brief
* tests wether comparison of y-order of two covertical points is known
* in advance
*/
template < class Point_2 >
inline bool knows_y_order(const Point_2& p) const {
//std::cout << "ACPf: knows_y_order" << std::endl;
if (dynamic_cast<const Point_2*>(this)) {
return p.knows_y_order(*(dynamic_cast<const Point_2*>(this)));
}
return knows_y_order(static_cast<Self>(p));
}
#endif
/*!\brief
* computes known y-order of covertical points
*/
inline
#ifndef SoX_GAPS_NO_VIRTUAL_DISPATCH
virtual
#endif
CGAL::Comparison_result known_y_order(const Self& p) const {
//std::cout << "ACP: known_y_order" << std::endl;
return CGAL::EQUAL;
}
#ifndef SoX_GAPS_NO_VIRTUAL_DISPATCH
/*!\brief
* computes known y-order of covertical points
*/
template < class Point_2 >
inline CGAL::Comparison_result known_y_order(const Point_2& t) const {
//std::cout << "ACPf: known_y_order" << std::endl;
if (dynamic_cast<const Point_2*>(this)) {
return -t.known_y_order(*(dynamic_cast<const Point_2*>(this)));
}
return known_y_order(static_cast<Self>(t));
}
#endif
/*!\brief
* tests wether y_order of covertical points need to be reversed
*/
inline
#ifndef SoX_GAPS_NO_VIRTUAL_DISPATCH
virtual
#endif
bool reverse_y_order(const Self& p) const {
//std::cout << "ACP: reverse_y_order" << std::endl;
return false;
}
#ifndef SoX_GAPS_NO_VIRTUAL_DISPATCH
/*!\brief
* tests wether y_order of covertical points needs to be reversed
*/
template < class Point_2 >
inline bool reverse_y_order(const Point_2& t) const {
//std::cout << "ACPf: reverse_y_order" << std::endl;
if (dynamic_cast<const Point_2*>(this)) {
return t.reverse_y_order(*(dynamic_cast<const Point_2*>(this)));
}
return reverse_y_order(static_cast<Self>(t));
}
#endif
//!@}
//!\name Comparisons
//!@{
public:
//!\name comparison predicates
//!@{
/*!\brief
* compares x-coordinates of \c *this with \c q
*
* do we need this method or one should use Algebraic_curve_kernel_2
* directly ?
*/
template < class Point_2 >
CGAL::Comparison_result compare_x(const Point_2& q) const {
CGAL::Comparison_result compare_x(const Self& q) const
{
if(this->is_identical(q)) {
return CGAL::EQUAL;
}
@ -374,8 +255,7 @@ public:
/*!\brief
* compares \c *this with \c q lexicographically
*/
template < class Point_2 >
CGAL::Comparison_result compare_xy(const Point_2& q,
CGAL::Comparison_result compare_xy(const Self& q,
bool equal_x = false) const
{
if(this->is_identical(q)) {
@ -388,79 +268,66 @@ public:
return c;
}
}
// else
return this->compare_y_at_x(q);
return this->_compare_y_at_x(q);
}
//! equality
template < class Point_2 >
bool operator == (const Point_2& q) const {return q.compare_xy(*this)== 0;}
bool operator == (const Self& q) const {return q.compare_xy(*this)== 0;}
//! inequality
template < class Point_2 >
bool operator != (const Point_2& q) const {return q.compare_xy(*this)!= 0;}
bool operator != (const Self& q) const {return q.compare_xy(*this)!= 0;}
//! less than in (x,y) lexicographic order
template < class Point_2 >
bool operator < (const Point_2& q) const {return q.compare_xy(*this)> 0;}
bool operator < (const Self& q) const {return q.compare_xy(*this)> 0;}
//! less-equal in (x,y) lexicographic order
template < class Point_2 >
bool operator <= (const Point_2& q) const {return q.compare_xy(*this)>= 0;}
bool operator <= (const Self& q) const {return q.compare_xy(*this)>= 0;}
//! greater than in (x,y) lexicographic order
template < class Point_2 >
bool operator > (const Point_2& q) const {return q.compare_xy(*this)< 0;}
bool operator > (const Self& q) const {return q.compare_xy(*this)< 0;}
//! greater-equal in (x,y) lexicographic order
template < class Point_2 >
bool operator >= (const Point_2& q) const {return q.compare_xy(*this)<= 0;}
bool operator >= (const Self& q) const {return q.compare_xy(*this)<= 0;}
//!@}
private:
//!@{
//! \name
/*!\brief
* compares y-coordinates for covertical points \c *this and \c q
*
* \pre x() == q.x()
*/
template < class Point_2 >
CGAL::Comparison_result compare_y_at_x(const Point_2& q) const
CGAL::Comparison_result _compare_y_at_x(const Self& q) const
{
CGAL_precondition(q.compare_x(*this) == CGAL::EQUAL);
// known filter
if (this->knows_y_order(q)) {
return this->known_y_order(q);
}
Curve_2 f = this->curve();
Curve_2 g = q.curve();
if(!f.is_identical(g)) { // common parts of curves?
if (this->simplify(*this,q)) {
if(this->_simplify(*this,q)) {
// ask for predicate again
// since this->curve() and this->curve() can be the
// equal now
return this->compare_y_at_x(q);
return this->_compare_y_at_x(q);
}
}
if (f.is_identical(g)) {
CGAL::Sign result = CGAL::sign(this->arcno() - q.arcno());
if (reverse_y_order(q))
return -result;
return result;
}
// attention: here the cache should be used
const Curve_pair_vertical_line_1& vline =
Curve_pair_analysis_2(
Curve_pair_2(f, g)).vertical_line_for_x(x());
Curve_pair_analysis_2(Curve_pair_2(f, g)).vertical_line_for_x(x());
CGAL::Sign result =
CGAL::sign(vline.get_event_of_curve(0, this->arcno()) -
vline.get_event_of_curve(1, q.arcno()));
if(reverse_y_order(q))
return -result;
return result;
}
//!@}
//!@}
public:
//!\name Reconstructing functions
//!@{
@ -525,12 +392,12 @@ public:
} else
cid = (p.first == -1 ? 1 : 0);
// overwrite data
this->ptr()->curve_ = pair.get_curve_analysis(cid).get_polynomial_2();
this->ptr()->arcno_ = (cid == 0 ? p.first : p.second);
this->ptr()->_m_curve =
pair.get_curve_analysis(cid).get_polynomial_2();
this->ptr()->_m_arcno = (cid == 0 ? p.first : p.second);
}
//!@}
}; // class Xy_coordinate_2
} // namespace CGALi