mirror of https://github.com/CGAL/cgal
Supporting files (tested with ConiX)
This commit is contained in:
parent
bbc1648717
commit
eefb69ff8d
|
|
@ -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_ >
|
||||
|
|
@ -32,29 +28,29 @@ template < class AlgebraicCurveKernel_2 >
|
|||
class Curve_analysis_2_rep {
|
||||
|
||||
public:
|
||||
// this first template argument
|
||||
typedef AlgebraicCurveKernel_2 Algebraic_curve_kernel_2;
|
||||
// this first template argument
|
||||
typedef AlgebraicCurveKernel_2 Algebraic_curve_kernel_2;
|
||||
|
||||
// myself
|
||||
// myself
|
||||
typedef Curve_analysis_2_rep<Algebraic_curve_kernel_2> Self;
|
||||
|
||||
typedef typename Algebraic_curve_kernel_2::Curve_pair_2 Curve_pair_2;
|
||||
typedef typename Algebraic_curve_kernel_2::Curve_pair_2 Curve_pair_2;
|
||||
|
||||
typedef typename Curve_pair_2::Algebraic_curve_2 Curve_2;
|
||||
|
||||
// constructors
|
||||
typedef typename Curve_pair_2::Algebraic_curve_2 Curve_2;
|
||||
|
||||
// constructors
|
||||
public:
|
||||
// default constructor ()
|
||||
Curve_analysis_2_rep()
|
||||
{ }
|
||||
{ }
|
||||
|
||||
// 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_;
|
||||
// temporarily this implementation uses underlying Curve_2 from SweepX
|
||||
mutable Curve_2 _m_curve;
|
||||
|
||||
// befriending the handle
|
||||
friend class Curve_analysis_2<Algebraic_curve_kernel_2, Self>;
|
||||
|
|
@ -71,163 +67,169 @@ public:
|
|||
//! entries. Topological information are equal for all x-coordinate inside such
|
||||
//! an open interval.
|
||||
template <class AlgebraicCurveKernel_2,
|
||||
class Rep_ = CGALi::Curve_analysis_2_rep<AlgebraicCurveKernel_2> >
|
||||
class Rep_ = CGALi::Curve_analysis_2_rep<AlgebraicCurveKernel_2> >
|
||||
class Curve_analysis_2 : public ::CGAL::Handle_with_policy< Rep_ >
|
||||
{
|
||||
public:
|
||||
//!@{
|
||||
//! \name typedefs
|
||||
//!@{
|
||||
//! \name typedefs
|
||||
|
||||
//! this instance's first template parameter
|
||||
typedef AlgebraicCurveKernel_2 Algebraic_curve_kernel_2;
|
||||
typedef AlgebraicCurveKernel_2 Algebraic_curve_kernel_2;
|
||||
|
||||
//! this instance's second template parameter
|
||||
typedef Rep_ Rep;
|
||||
|
||||
//! x-coordinate type
|
||||
typedef typename Algebraic_curve_kernel_2::X_coordinate_1 X_coordinate_1;
|
||||
typedef Rep_ Rep;
|
||||
|
||||
//! x-coordinate type
|
||||
typedef typename Algebraic_curve_kernel_2::X_coordinate_1 X_coordinate_1;
|
||||
|
||||
//! type of a curve point
|
||||
typedef typename Algebraic_curve_kernel_2::Xy_coordinate_2 Xy_coordinate_2;
|
||||
//! type of a curve point
|
||||
typedef typename Algebraic_curve_kernel_2::Xy_coordinate_2 Xy_coordinate_2;
|
||||
|
||||
//! type of a curve
|
||||
typedef typename Algebraic_curve_kernel_2::Curve_2 Curve_2;
|
||||
//! type of a curve
|
||||
typedef typename Algebraic_curve_kernel_2::Curve_2 Curve_2;
|
||||
|
||||
//! myself
|
||||
typedef Curve_analysis_2<Algebraic_curve_kernel_2, Rep> Self;
|
||||
//! myself
|
||||
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;
|
||||
//! type of a vertical line
|
||||
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;
|
||||
|
||||
//!@}
|
||||
//!\name Constructors
|
||||
//!@{
|
||||
//! 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))
|
||||
{ }
|
||||
//! \brief constructs a curve analysis from a given \c Curve_2 object
|
||||
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) {
|
||||
}
|
||||
|
||||
//!@}
|
||||
//!\name Access functions
|
||||
//!@{
|
||||
//!@}
|
||||
public:
|
||||
//!\name Access functions
|
||||
//!@{
|
||||
|
||||
//! \brief returns the defining polynomial of the analysis
|
||||
Curve_2 get_polynomial_2() const
|
||||
{
|
||||
return this->ptr()->curve_;
|
||||
}
|
||||
//! \brief returns the defining polynomial of the analysis
|
||||
Curve_2 get_polynomial_2() const
|
||||
{
|
||||
return this->ptr()->_m_curve;
|
||||
}
|
||||
|
||||
//! \brief alias for \c get_polynomial_2()
|
||||
Curve_2 get_curve_2() const
|
||||
{
|
||||
return get_polynomial_2();
|
||||
}
|
||||
//! \brief alias for \c get_polynomial_2()
|
||||
Curve_2 get_curve_2() const
|
||||
{
|
||||
return get_polynomial_2();
|
||||
}
|
||||
|
||||
//! \brief returns number of vertical lines that encode an event
|
||||
int number_of_vertical_lines_with_event() const
|
||||
{
|
||||
return this->ptr()->curve_.num_events();
|
||||
}
|
||||
//! \brief returns number of vertical lines that encode an event
|
||||
int number_of_vertical_lines_with_event() const
|
||||
{
|
||||
return this->ptr()->_m_curve.num_events();
|
||||
}
|
||||
|
||||
//! \brief returns an instance of \c CurveVerticalLine_1 at the i-th
|
||||
//! event
|
||||
//!
|
||||
//! \pre 0 <= i < number_of_vertical_lines_with_event()
|
||||
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),
|
||||
*this, i);
|
||||
}
|
||||
//! \brief returns an instance of \c CurveVerticalLine_1 at the i-th
|
||||
//! event
|
||||
//!
|
||||
//! \pre 0 <= i < number_of_vertical_lines_with_event()
|
||||
Curve_vertical_line_1 vertical_line_at_event(int i) const
|
||||
{
|
||||
CGAL_precondition(i >= 0&&i < number_of_vertical_lines_with_event());
|
||||
return Curve_vertical_line_1(this->ptr()->_m_curve.event_info(i),
|
||||
*this, i);
|
||||
}
|
||||
|
||||
//! \brief returns an instance of CurveVerticalLine_1 of the i-th
|
||||
//! interval
|
||||
//!
|
||||
//! \pre 0 <= i < number_of_vertical_lines_with_event()
|
||||
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);
|
||||
// # 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);
|
||||
// initialize n continuous arcs
|
||||
std::vector<SoX::Curve_arc_2 > dummy_arcs(n_arcs);
|
||||
ei.set_arcs(dummy_arcs);
|
||||
ei.fix();
|
||||
return Curve_vertical_line_1(ei, *this, i);
|
||||
}
|
||||
//! \brief returns an instance of CurveVerticalLine_1 of the i-th
|
||||
//! interval
|
||||
//!
|
||||
//! \pre 0 <= i < number_of_vertical_lines_with_event()
|
||||
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()->_m_curve.arcs_over_interval(i);
|
||||
// # of arcs to the left and to the right is the same over an interval
|
||||
Event1_info ei(X_coordinate_1(this->ptr()->_m_curve.
|
||||
boundary_value_in_interval(i)), n_arcs, n_arcs);
|
||||
|
||||
// initialize n continuous 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);
|
||||
}
|
||||
|
||||
//! \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
|
||||
//! event, then \c vertical_line_of_interval(i)
|
||||
//! (\c vertical_line_of_interval(i+1)) is returned.
|
||||
//!
|
||||
//! \pre \c x is finite
|
||||
Curve_vertical_line_1 vertical_line_for_x(X_coordinate_1 x,
|
||||
CGAL::Sign perturb = CGAL::ZERO) const
|
||||
{
|
||||
// CGAL_precondition(x is finite ??);
|
||||
int i;
|
||||
bool is_evt;
|
||||
this->ptr()->curve_.x_to_index(x, i, is_evt);
|
||||
if(is_evt) {
|
||||
if(perturb == CGAL::ZERO)
|
||||
return vertical_line_at_event(i);
|
||||
if(perturb == CGAL::POSITIVE)
|
||||
i++;
|
||||
}
|
||||
return vertical_line_of_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
|
||||
//! event, then \c vertical_line_of_interval(i)
|
||||
//! (\c vertical_line_of_interval(i+1)) is returned.
|
||||
//!
|
||||
//! \pre \c x is finite
|
||||
Curve_vertical_line_1 vertical_line_for_x(X_coordinate_1 x,
|
||||
CGAL::Sign perturb = CGAL::ZERO) const
|
||||
{
|
||||
// CGAL_precondition(x is finite ??);
|
||||
int i;
|
||||
bool 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);
|
||||
if(perturb == CGAL::POSITIVE)
|
||||
i++;
|
||||
}
|
||||
return vertical_line_of_interval(i);
|
||||
}
|
||||
|
||||
//! \brief returns an instance of CurveVerticalLine_1 at a given \c x
|
||||
//!
|
||||
//! \pre \c x is finite
|
||||
Curve_vertical_line_1 vertical_line_at_exact_x(X_coordinate_1 x) const
|
||||
{
|
||||
// CGAL_precondition(x is finite ??);
|
||||
int i;
|
||||
bool is_evt;
|
||||
this->ptr()->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);
|
||||
// initialize n continuous arcs
|
||||
std::vector<SoX::Curve_arc_2 > dummy_arcs(n_arcs);
|
||||
ei.set_arcs(dummy_arcs);
|
||||
ei.fix();
|
||||
return Curve_vertical_line_1(ei, *this, i);
|
||||
}
|
||||
|
||||
//! \brief returns an instance of CurveVerticalLine_1 at a given \c x
|
||||
//!
|
||||
//! \pre \c x is finite
|
||||
Curve_vertical_line_1 vertical_line_at_exact_x(X_coordinate_1 x) const
|
||||
{
|
||||
// CGAL_precondition(x is finite ??);
|
||||
int i;
|
||||
bool 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()->_m_curve.arcs_over_interval(i);
|
||||
Event1_info ei(x, n_arcs, n_arcs);
|
||||
// initialize n continuous 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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
@ -32,42 +27,42 @@ template < class AlgebraicCurveKernel_2 >
|
|||
class Curve_pair_analysis_2_rep {
|
||||
|
||||
public:
|
||||
// this first template argument
|
||||
typedef AlgebraicCurveKernel_2 Algebraic_curve_kernel_2;
|
||||
// this first template argument
|
||||
typedef AlgebraicCurveKernel_2 Algebraic_curve_kernel_2;
|
||||
|
||||
// myself
|
||||
// myself
|
||||
typedef Curve_pair_analysis_2_rep<Algebraic_curve_kernel_2> Self;
|
||||
|
||||
// type of curve pair
|
||||
typedef typename Algebraic_curve_kernel_2::Curve_pair_2 Curve_pair_2;
|
||||
|
||||
// type of 1-curve analysis
|
||||
typedef typename Algebraic_curve_kernel_2::Curve_analysis_2
|
||||
Curve_analysis_2;
|
||||
// type of curve pair
|
||||
typedef typename Algebraic_curve_kernel_2::Curve_pair_2 Curve_pair_2;
|
||||
|
||||
// type of 1-curve analysis
|
||||
typedef typename Algebraic_curve_kernel_2::Curve_analysis_2
|
||||
Curve_analysis_2;
|
||||
|
||||
// constructors
|
||||
// constructors
|
||||
public:
|
||||
// default constructor ()
|
||||
Curve_pair_analysis_2_rep()
|
||||
{ }
|
||||
Curve_pair_analysis_2_rep()
|
||||
{ }
|
||||
|
||||
// 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())
|
||||
{ }
|
||||
// constructs from two curve analysis
|
||||
Curve_pair_analysis_2_rep(const Curve_analysis_2& ca1,
|
||||
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_;
|
||||
|
||||
// temporarily this implementation uses underlying Curve_pair_2 from SweepX
|
||||
mutable Curve_pair_2 curve_pair_;
|
||||
mutable Curve_analysis_2 _m_ca1, _m_ca2;
|
||||
|
||||
// temporarily this implementation uses underlying Curve_pair_2 from SweepX
|
||||
mutable Curve_pair_2 _m_curve_pair;
|
||||
|
||||
// befriending the handle
|
||||
friend class Curve_pair_analysis_2<Algebraic_curve_kernel_2, Self>;
|
||||
|
|
@ -84,161 +79,169 @@ public:
|
|||
//! between one such interval differ only in the values of the
|
||||
//! \c Algebraic_real_2 entries. Topological information are equal.
|
||||
template <class AlgebraicCurveKernel_2,
|
||||
class Rep_ = CGALi::Curve_pair_analysis_2_rep<AlgebraicCurveKernel_2> >
|
||||
class Rep_ = CGALi::Curve_pair_analysis_2_rep<AlgebraicCurveKernel_2> >
|
||||
class Curve_pair_analysis_2 : public ::CGAL::Handle_with_policy< Rep_ >
|
||||
{
|
||||
public:
|
||||
//!@{
|
||||
//! \name typedefs
|
||||
//!@{
|
||||
//! \name typedefs
|
||||
|
||||
//! this instance's first template parameter
|
||||
typedef AlgebraicCurveKernel_2 Algebraic_curve_kernel_2;
|
||||
typedef AlgebraicCurveKernel_2 Algebraic_curve_kernel_2;
|
||||
|
||||
//! this instance's second template parameter
|
||||
typedef Rep_ Rep;
|
||||
typedef Rep_ Rep;
|
||||
|
||||
//! x-coordinate type
|
||||
typedef typename Algebraic_curve_kernel_2::X_coordinate_1 X_coordinate_1;
|
||||
//! x-coordinate type
|
||||
typedef typename Algebraic_curve_kernel_2::X_coordinate_1 X_coordinate_1;
|
||||
|
||||
//! type of a curve point
|
||||
typedef typename Algebraic_curve_kernel_2::Xy_coordinate_2 Xy_coordinate_2;
|
||||
//! type of a curve point
|
||||
typedef typename Algebraic_curve_kernel_2::Xy_coordinate_2 Xy_coordinate_2;
|
||||
|
||||
//! type of a curve pair
|
||||
typedef typename Algebraic_curve_kernel_2::Curve_pair_2 Curve_pair_2;
|
||||
//! type of a curve pair
|
||||
typedef typename Algebraic_curve_kernel_2::Curve_pair_2 Curve_pair_2;
|
||||
|
||||
//! type of a curve
|
||||
typedef typename Algebraic_curve_kernel_2::Curve_2 Curve_2;
|
||||
//! type of a curve
|
||||
typedef typename Algebraic_curve_kernel_2::Curve_2 Curve_2;
|
||||
|
||||
//! type of 1-curve analysis
|
||||
typedef typename Algebraic_curve_kernel_2::Curve_analysis_2
|
||||
Curve_analysis_2;
|
||||
//! type of 1-curve analysis
|
||||
typedef typename Algebraic_curve_kernel_2::Curve_analysis_2
|
||||
Curve_analysis_2;
|
||||
|
||||
//! myself
|
||||
typedef Curve_pair_analysis_2<Algebraic_curve_kernel_2, Rep> Self;
|
||||
//! myself
|
||||
typedef Curve_pair_analysis_2<Algebraic_curve_kernel_2, Rep> Self;
|
||||
|
||||
//! type of a vertical line
|
||||
typedef CGALi::Curve_pair_vertical_line_1<Self>
|
||||
Curve_pair_vertical_line_1;
|
||||
|
||||
//! the handle superclass
|
||||
typedef ::CGAL::Handle_with_policy< Rep > Base;
|
||||
//! type of a vertical line
|
||||
typedef CGALi::Curve_pair_vertical_line_1<Self>
|
||||
Curve_pair_vertical_line_1;
|
||||
|
||||
//! the handle superclass
|
||||
typedef ::CGAL::Handle_with_policy<Rep> Base;
|
||||
|
||||
//!@}
|
||||
//!\name Constructors
|
||||
//!@{
|
||||
//!@}
|
||||
public:
|
||||
//!\name Constructors
|
||||
//!@{
|
||||
|
||||
//! \brief default constructor
|
||||
Curve_pair_analysis_2() : Base(Rep())
|
||||
{ }
|
||||
//! \brief default constructor
|
||||
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
|
||||
//! must be squarefree and coprime.
|
||||
Curve_pair_analysis_2(const Curve_analysis_2& ca1_,
|
||||
const Curve_analysis_2& ca2_) : Base(Rep(ca1_, ca2_))
|
||||
{ }
|
||||
//! constructs a curve pair analysis defined by 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)) {
|
||||
}
|
||||
|
||||
// temporary constructor to construct directly from curve pair
|
||||
Curve_pair_analysis_2(const Curve_pair_2& curve_pair_) :
|
||||
Base(Rep(curve_pair_))
|
||||
{ }
|
||||
// temporary constructor to construct directly from 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) {
|
||||
}
|
||||
|
||||
//!@}
|
||||
//!\name Access functions
|
||||
//!@{
|
||||
//!@}
|
||||
public:
|
||||
//!\name Access functions
|
||||
//!@{
|
||||
|
||||
//! \brief returns curve analysis for c-"th" curve (0 or 1)
|
||||
Curve_analysis_2 get_curve_analysis(bool c) const
|
||||
{
|
||||
if(c == 0)
|
||||
return this->ptr()->ca1_;
|
||||
return this->ptr()->ca2_;
|
||||
}
|
||||
//! \brief returns curve analysis for c-"th" curve (0 or 1)
|
||||
Curve_analysis_2 get_curve_analysis(bool c) const
|
||||
{
|
||||
if(c == 0)
|
||||
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();
|
||||
}
|
||||
//! \brief returns number of vertical lines that encode an event
|
||||
int number_of_vertical_lines_with_event() const
|
||||
{
|
||||
return this->ptr()->_m_curve_pair.num_events();
|
||||
}
|
||||
|
||||
//! \brief given the i-th event of the curve pair this method returns the
|
||||
//! id of the event of the corresponding curve analysis \c c (0 or 1),
|
||||
//! or -1, if the curve has no event at this coordinate.
|
||||
//!
|
||||
//! \pre 0 <= i < number_of_vertical_lines_with_event()
|
||||
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);
|
||||
return (c == 0 ? triple.ffy : triple.ggy);
|
||||
}
|
||||
//! \brief given the i-th event of the curve pair this method returns the
|
||||
//! id of the event of the corresponding curve analysis \c c (0 or 1),
|
||||
//! or -1, if the curve has no event at this coordinate.
|
||||
//!
|
||||
//! \pre 0 <= i < number_of_vertical_lines_with_event()
|
||||
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()->_m_curve_pair.event_indices(i);
|
||||
return (c == 0 ? triple.ffy : triple.ggy);
|
||||
}
|
||||
|
||||
//! \brief returns an instance of \c CurvePairVerticalLine_1 at the i-th
|
||||
//! event
|
||||
//!
|
||||
//! \pre 0 <= i < number_of_vertical_lines_with_event()
|
||||
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);
|
||||
}
|
||||
//! \brief returns an instance of \c CurvePairVerticalLine_1 at the i-th
|
||||
//! event
|
||||
//!
|
||||
//! \pre 0 <= i < number_of_vertical_lines_with_event()
|
||||
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()->_m_curve_pair.slice_at_event(i);
|
||||
}
|
||||
|
||||
//! \brief returns an instance of CurvePairVerticalLine_1 of the i-th
|
||||
//! interval between x-events
|
||||
//!
|
||||
//! \pre 0 <= i < number_of_vertical_lines_with_event()
|
||||
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);
|
||||
}
|
||||
//! \brief returns an instance of CurvePairVerticalLine_1 of the i-th
|
||||
//! interval between x-events
|
||||
//!
|
||||
//! \pre 0 <= i < number_of_vertical_lines_with_event()
|
||||
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()->_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
|
||||
//! event, then \c vertical_line_of_interval(i)
|
||||
//! (\c vertical_line_of_interval(i+1)) is returned.
|
||||
//!
|
||||
//! \pre \c x is finite
|
||||
Curve_pair_vertical_line_1 vertical_line_for_x(X_coordinate_1 x,
|
||||
CGAL::Sign perturb = CGAL::ZERO) const
|
||||
{
|
||||
// CGAL_precondition(x is finite ??);
|
||||
int i;
|
||||
bool is_evt;
|
||||
this->ptr()->curve_pair_.x_to_index(x, i, is_evt);
|
||||
if(is_evt) {
|
||||
if(perturb == CGAL::ZERO)
|
||||
return vertical_line_at_event(i);
|
||||
if(perturb == CGAL::POSITIVE)
|
||||
i++;
|
||||
}
|
||||
return vertical_line_of_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 (\c CGAL::POSITIVE) and x states an
|
||||
//! event, then \c vertical_line_of_interval(i)
|
||||
//! (\c vertical_line_of_interval(i+1)) is returned.
|
||||
//!
|
||||
//! \pre \c x is finite
|
||||
Curve_pair_vertical_line_1 vertical_line_for_x(X_coordinate_1 x,
|
||||
CGAL::Sign perturb = CGAL::ZERO) const
|
||||
{
|
||||
// CGAL_precondition(x is finite ??);
|
||||
int i;
|
||||
bool 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);
|
||||
if(perturb == CGAL::POSITIVE)
|
||||
i++;
|
||||
}
|
||||
return vertical_line_of_interval(i);
|
||||
}
|
||||
|
||||
//! \brief returns an instance of CurvePairVerticalLine_1 at a given \c x
|
||||
//!
|
||||
//! \pre \c x is finite
|
||||
Curve_pair_vertical_line_1 vertical_line_at_exact_x(X_coordinate_1 x) const
|
||||
{
|
||||
// CGAL_precondition(x is finite ??);
|
||||
return vertical_line_for_x(x);
|
||||
}
|
||||
//! \brief returns an instance of CurvePairVerticalLine_1 at a given \c x
|
||||
//!
|
||||
//! \pre \c x is finite
|
||||
Curve_pair_vertical_line_1 vertical_line_at_exact_x(X_coordinate_1 x) const
|
||||
{
|
||||
// CGAL_precondition(x is finite ??);
|
||||
return vertical_line_for_x(x);
|
||||
}
|
||||
|
||||
//!@}
|
||||
}; // class Curve_pair_analysis_2
|
||||
|
||||
} // namespace CGALi
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
@ -30,47 +26,47 @@ class Curve_pair_vertical_line_1;
|
|||
|
||||
template <class CurvePairAnalysis_2, class Rep>
|
||||
std::ostream& operator<< (std::ostream&,
|
||||
const Curve_pair_vertical_line_1<CurvePairAnalysis_2, Rep>&);
|
||||
const Curve_pair_vertical_line_1<CurvePairAnalysis_2, Rep>&);
|
||||
|
||||
template < class CurvePairAnalysis_2 >
|
||||
class Curve_pair_vertical_line_1_rep {
|
||||
|
||||
// this template argument
|
||||
typedef CurvePairAnalysis_2 Curve_pair_analysis_2;
|
||||
// this template argument
|
||||
typedef CurvePairAnalysis_2 Curve_pair_analysis_2;
|
||||
|
||||
// myself
|
||||
// myself
|
||||
typedef Curve_pair_vertical_line_1_rep<Curve_pair_analysis_2> Self;
|
||||
|
||||
// type of x-coordinate
|
||||
typedef typename Curve_pair_analysis_2::X_coordinate_1
|
||||
X_coordinate_1;
|
||||
// type of x-coordinate
|
||||
typedef typename Curve_pair_analysis_2::X_coordinate_1
|
||||
X_coordinate_1;
|
||||
|
||||
// type of a curve point
|
||||
typedef typename Curve_pair_analysis_2::Xy_coordinate_2
|
||||
Xy_coordinate_2;
|
||||
// type of a curve point
|
||||
typedef typename Curve_pair_analysis_2::Xy_coordinate_2
|
||||
Xy_coordinate_2;
|
||||
|
||||
// type of internal algebraic curve pair
|
||||
typedef typename Curve_pair_analysis_2::Curve_pair_2 Curve_pair_2;
|
||||
// type of internal algebraic curve pair
|
||||
typedef typename Curve_pair_analysis_2::Curve_pair_2 Curve_pair_2;
|
||||
|
||||
// type of underlying \c Event2_slice
|
||||
typedef typename Curve_pair_2::Event2_slice Event2_slice;
|
||||
// type of underlying \c Event2_slice
|
||||
typedef typename Curve_pair_2::Event2_slice Event2_slice;
|
||||
|
||||
// constructors
|
||||
// constructors
|
||||
public:
|
||||
// default constructor ()
|
||||
Curve_pair_vertical_line_1_rep()
|
||||
{ }
|
||||
{ }
|
||||
|
||||
// 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_;
|
||||
// underlying Event2_slice object (temporary)
|
||||
mutable Event2_slice _m_event_slice;
|
||||
|
||||
// befriending the handle
|
||||
// befriending the handle
|
||||
friend class Curve_pair_vertical_line_1<Curve_pair_analysis_2, Self>;
|
||||
};
|
||||
|
||||
|
|
@ -84,13 +80,13 @@ public:
|
|||
//! also holds for curve ends approaching the vertical asymptote.
|
||||
//! Curve_pair_vertical_line_1 at x = +/-oo are not allowed.
|
||||
template <class CurvePairAnalysis_2,
|
||||
class Rep_ = CGALi::Curve_pair_vertical_line_1_rep<CurvePairAnalysis_2> >
|
||||
class Rep_ = CGALi::Curve_pair_vertical_line_1_rep<CurvePairAnalysis_2> >
|
||||
class Curve_pair_vertical_line_1 :
|
||||
public ::CGAL::Handle_with_policy< Rep_ >
|
||||
public ::CGAL::Handle_with_policy< Rep_ >
|
||||
{
|
||||
public:
|
||||
//!@{
|
||||
//!\name typedefs
|
||||
//!@{
|
||||
//!\name typedefs
|
||||
|
||||
//! this instance's first template parameter
|
||||
typedef CurvePairAnalysis_2 Curve_pair_analysis_2;
|
||||
|
|
@ -101,165 +97,165 @@ public:
|
|||
//! this instance itself
|
||||
typedef Curve_pair_vertical_line_1<Curve_pair_analysis_2, Rep> Self;
|
||||
|
||||
//! type of internal algebraic curve pair
|
||||
typedef typename Curve_pair_analysis_2::Curve_pair_2 Curve_pair_2;
|
||||
//! type of internal algebraic curve pair
|
||||
typedef typename Curve_pair_analysis_2::Curve_pair_2 Curve_pair_2;
|
||||
|
||||
//! type of x-coordinate
|
||||
typedef typename Curve_pair_analysis_2::X_coordinate_1 X_coordinate_1;
|
||||
//! type of x-coordinate
|
||||
typedef typename Curve_pair_analysis_2::X_coordinate_1 X_coordinate_1;
|
||||
|
||||
//! type of a curve point
|
||||
typedef typename Curve_pair_analysis_2::Xy_coordinate_2 Xy_coordinate_2;
|
||||
//! type of a curve point
|
||||
typedef typename Curve_pair_analysis_2::Xy_coordinate_2 Xy_coordinate_2;
|
||||
|
||||
//! type of underlying \c Event2_slice
|
||||
typedef typename Curve_pair_2::Event2_slice Event2_slice;
|
||||
//! type of underlying \c Event2_slice
|
||||
typedef typename Curve_pair_2::Event2_slice Event2_slice;
|
||||
|
||||
//! the handle superclass
|
||||
//! the handle superclass
|
||||
typedef ::CGAL::Handle_with_policy< Rep > Base;
|
||||
|
||||
//!@}
|
||||
//!@}
|
||||
public:
|
||||
//!\name constructors
|
||||
//!\name constructors
|
||||
//!@{
|
||||
|
||||
/*!\brief
|
||||
/*!\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
|
||||
/*!\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:
|
||||
//!@}
|
||||
//!\name access functions
|
||||
//!@{
|
||||
|
||||
// overriden member function while the class doesn't have it's own
|
||||
// representation
|
||||
bool is_identical(const Self& line) const
|
||||
{
|
||||
return this->ptr()->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();
|
||||
if(is_event())
|
||||
return this->ptr()->event_slice_.curve_pair().event_x(id);
|
||||
return X_coordinate_1(this->ptr()->event_slice_.curve_pair().
|
||||
boundary_value_in_interval(id));
|
||||
}
|
||||
|
||||
//! \brief returns number of distinct and finite intersections of a pair
|
||||
//! of curves with a (intended) vertical line ignoring a real vertical
|
||||
//! line component of the curve at the given x-coordinate.
|
||||
int number_of_events() const
|
||||
{
|
||||
return (this->ptr()->event_slice_.num_arcs());
|
||||
}
|
||||
//!@}
|
||||
//!\name access functions
|
||||
//!@{
|
||||
|
||||
// overriden member function while the class doesn't have it's own
|
||||
// representation
|
||||
bool is_identical(const Self& line) const
|
||||
{
|
||||
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()->_m_event_slice.id();
|
||||
if(is_event())
|
||||
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));
|
||||
}
|
||||
|
||||
//! \brief returns number of distinct and finite intersections of a pair
|
||||
//! of curves with a (intended) vertical line ignoring a real vertical
|
||||
//! line component of the curve at the given x-coordinate.
|
||||
int number_of_events() const
|
||||
{
|
||||
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)
|
||||
//! curve in the sequence of events.
|
||||
//!
|
||||
//! 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()
|
||||
int get_event_of_curve(int k, bool c) const
|
||||
{
|
||||
typename Event2_slice::Int_container ic =
|
||||
this->ptr()->event_slice_.arcno_to_pos
|
||||
((c == 0 ? SoX::CURVE1 : SoX::CURVE2));
|
||||
CGAL_precondition(0 <= k && k < static_cast<int>(ic.size()));
|
||||
return (ic[k]);
|
||||
}
|
||||
//! \brief returns the y-position of the k-th event of the c-th (0 or 1)
|
||||
//! curve in the sequence of events.
|
||||
//!
|
||||
//! Note that each event is formed by the first, the second, or both curves
|
||||
//!
|
||||
//! \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()->_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]);
|
||||
}
|
||||
|
||||
//! \brief returns the multiplicity of intersection defined at event with
|
||||
//! position \c j. May return 0 in case multiplicity is unknown.
|
||||
//!
|
||||
//! \pre There is an intersection of both curves at j-th event
|
||||
//! \pre 0 <= j < number_of_events()
|
||||
int get_multiplicity_of_intersection(int j) const
|
||||
{
|
||||
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);
|
||||
CGAL_precondition(arc.first == SoX::CURVE_BOTH);
|
||||
return arc.second;
|
||||
}
|
||||
//! \brief returns the multiplicity of intersection defined at event with
|
||||
//! position \c j. May return 0 in case multiplicity is unknown.
|
||||
//!
|
||||
//! \pre There is an intersection of both curves at j-th event
|
||||
//! \pre 0 <= j < number_of_events()
|
||||
int get_multiplicity_of_intersection(int j) const
|
||||
{
|
||||
CGAL_precondition(0 <= j && j < number_of_events());
|
||||
CGAL_precondition(is_event());
|
||||
const typename Event2_slice::Arc_at_event_2& arc =
|
||||
this->ptr()->_m_event_slice.arc_at_event(j);
|
||||
CGAL_precondition(arc.first == SoX::CURVE_BOTH);
|
||||
return arc.second;
|
||||
}
|
||||
|
||||
//! \brief returns a pair of \c int indicating whether event \c j is formed
|
||||
//! by which arc numbers of the first and the second curve, or -1, if the
|
||||
//! corresponding curve is not involved.
|
||||
//!
|
||||
//! \pre 0 <= j < number_of_events()
|
||||
std::pair<int, int> get_curves_at_event(int j) const
|
||||
{
|
||||
CGAL_precondition(0 <= j && j < number_of_events());
|
||||
typedef std::vector<typename Event2_slice::Arc_at_event_2>
|
||||
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;
|
||||
int idx[2] = {-1, -1};
|
||||
it = res.begin();
|
||||
idx[((*it).first == SoX::CURVE1 ? 0 : 1)] = (*it).second;
|
||||
if(++it != end)
|
||||
idx[((*it).first == SoX::CURVE1 ? 0 : 1)] = (*it).second;
|
||||
return std::make_pair(idx[0], idx[1]);
|
||||
}
|
||||
//! \brief returns a pair of \c int indicating whether event \c j is formed
|
||||
//! by which arc numbers of the first and the second curve, or -1, if the
|
||||
//! corresponding curve is not involved.
|
||||
//!
|
||||
//! \pre 0 <= j < number_of_events()
|
||||
std::pair<int, int> get_curves_at_event(int j) const
|
||||
{
|
||||
CGAL_precondition(0 <= j && j < number_of_events());
|
||||
typedef std::vector<typename Event2_slice::Arc_at_event_2>
|
||||
Arc_vector;
|
||||
Arc_vector res(2); // maximum two elements
|
||||
typename Arc_vector::iterator end =
|
||||
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;
|
||||
if(++it != end)
|
||||
idx[((*it).first == SoX::CURVE1 ? 0 : 1)] = (*it).second;
|
||||
return std::make_pair(idx[0], idx[1]);
|
||||
}
|
||||
|
||||
//! \brief returns true if a curve has an event or in case there is an
|
||||
//! intersection of both curves.
|
||||
bool is_event() const
|
||||
{
|
||||
return this->ptr()->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();
|
||||
}
|
||||
|
||||
// temporary access function (for testing)
|
||||
Event2_slice get_slice() const
|
||||
{
|
||||
return this->ptr()->event_slice_;
|
||||
}
|
||||
|
||||
friend std::ostream& operator << <>(std::ostream&, const Self&);
|
||||
//! \brief returns true if a curve has an event or in case there is an
|
||||
//! intersection of both curves.
|
||||
bool is_event() const
|
||||
{
|
||||
return this->ptr()->_m_event_slice.is_event();
|
||||
}
|
||||
|
||||
//! \brief returns true if there is an intersection of both curves.
|
||||
bool is_intersection() const
|
||||
{
|
||||
CGAL_precondition(is_event());
|
||||
return this->ptr()->_m_event_slice.is_intersection();
|
||||
}
|
||||
|
||||
// temporary access function (for testing)
|
||||
Event2_slice get_slice() const
|
||||
{
|
||||
return this->ptr()->_m_event_slice;
|
||||
}
|
||||
|
||||
//!@}
|
||||
}; // class Curve_pair_vertical_line_1
|
||||
|
||||
template <class CurvePairAnalysis_2, class Rep>
|
||||
std::ostream& operator<< (
|
||||
std::ostream& os,
|
||||
const CGALi::Curve_pair_vertical_line_1<CurvePairAnalysis_2, Rep>&
|
||||
cpv_line) {
|
||||
const CGALi::Curve_pair_vertical_line_1<CurvePairAnalysis_2, Rep>&
|
||||
cpv_line) {
|
||||
os << (cpv_line.get_slice());
|
||||
return os;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
@ -30,50 +26,51 @@ class Curve_vertical_line_1;
|
|||
|
||||
template <class CurveAnalysis_2, class Rep>
|
||||
std::ostream& operator<< (std::ostream&,
|
||||
const Curve_vertical_line_1<CurveAnalysis_2, Rep>&);
|
||||
const Curve_vertical_line_1<CurveAnalysis_2, Rep>&);
|
||||
|
||||
template < class CurveAnalysis_2 >
|
||||
class Curve_vertical_line_1_rep {
|
||||
|
||||
// this template argument
|
||||
typedef CurveAnalysis_2 Curve_analysis_2;
|
||||
// this template argument
|
||||
typedef CurveAnalysis_2 Curve_analysis_2;
|
||||
|
||||
// myself
|
||||
// myself
|
||||
typedef Curve_vertical_line_1_rep<Curve_analysis_2> Self;
|
||||
|
||||
// type of x-coordinate
|
||||
typedef typename Curve_analysis_2::X_coordinate_1
|
||||
X_coordinate_1;
|
||||
// type of x-coordinate
|
||||
typedef typename Curve_analysis_2::X_coordinate_1
|
||||
X_coordinate_1;
|
||||
|
||||
// type of a curve point
|
||||
typedef typename Curve_analysis_2::Xy_coordinate_2
|
||||
Xy_coordinate_2;
|
||||
// type of a curve point
|
||||
typedef typename Curve_analysis_2::Xy_coordinate_2
|
||||
Xy_coordinate_2;
|
||||
|
||||
//! type of underlying \c Event1_info
|
||||
typedef typename Curve_analysis_2::Curve_2::Event1_info Event1_info;
|
||||
//! type of underlying \c Event1_info
|
||||
typedef typename Curve_analysis_2::Curve_2::Event1_info Event1_info;
|
||||
|
||||
// constructors
|
||||
public:
|
||||
// default constructor ()
|
||||
Curve_vertical_line_1_rep()
|
||||
{ }
|
||||
{ }
|
||||
|
||||
// standard constructor
|
||||
// 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)
|
||||
{ }
|
||||
const Curve_analysis_2& ca_2, int 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 Curve_analysis_2 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
|
||||
|
||||
// befriending the handle
|
||||
// temporary added underlying Event1_info object
|
||||
mutable Event1_info _m_event_info;
|
||||
|
||||
mutable Curve_analysis_2 _m_ca_2; // supporting curve analysis
|
||||
|
||||
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>;
|
||||
};
|
||||
|
||||
|
|
@ -92,15 +89,15 @@ public:
|
|||
//! coordinates (x,?oo), resp. (x,+oo), occur only once, if they occur, and
|
||||
//! they imply not to be associated with a instance of \c Algebraic_real_2.
|
||||
template <class CurveAnalysis_2,
|
||||
class Rep_ = CGALi::Curve_vertical_line_1_rep<CurveAnalysis_2> >
|
||||
class Rep_ = CGALi::Curve_vertical_line_1_rep<CurveAnalysis_2> >
|
||||
class Curve_vertical_line_1
|
||||
: public ::CGAL::Handle_with_policy< Rep_ > {
|
||||
: public ::CGAL::Handle_with_policy< Rep_ > {
|
||||
public:
|
||||
//!@{
|
||||
//!\name typedefs
|
||||
//!@{
|
||||
//!\name typedefs
|
||||
|
||||
//! this instance's first template parameter
|
||||
//! model of AlgebraicKernel_d_2::CurveAnalysis_2
|
||||
//! model of AlgebraicKernel_d_2::CurveAnalysis_2
|
||||
typedef CurveAnalysis_2 Curve_analysis_2;
|
||||
|
||||
//! this instance's second template parameter
|
||||
|
|
@ -109,173 +106,169 @@ public:
|
|||
//! this instance itself
|
||||
typedef Curve_vertical_line_1<Curve_analysis_2, Rep> Self;
|
||||
|
||||
//! type of x-coordinate
|
||||
typedef typename Curve_analysis_2::X_coordinate_1 X_coordinate_1;
|
||||
//! type of x-coordinate
|
||||
typedef typename Curve_analysis_2::X_coordinate_1 X_coordinate_1;
|
||||
|
||||
//! type of a curve point
|
||||
typedef typename Curve_analysis_2::Xy_coordinate_2 Xy_coordinate_2;
|
||||
//! type of a curve point
|
||||
typedef typename Curve_analysis_2::Xy_coordinate_2 Xy_coordinate_2;
|
||||
|
||||
//! type of underlying \c Event1_info
|
||||
typedef typename Curve_analysis_2::Curve_2::Event1_info Event1_info;
|
||||
|
||||
//! the handle superclass
|
||||
//! type of underlying \c Event1_info
|
||||
typedef typename Curve_analysis_2::Curve_2::Event1_info Event1_info;
|
||||
|
||||
//! the handle superclass
|
||||
typedef ::CGAL::Handle_with_policy< Rep > Base;
|
||||
|
||||
//!@}
|
||||
//!@}
|
||||
public:
|
||||
//!\name constructors
|
||||
//!\name constructors
|
||||
//!@{
|
||||
|
||||
/*!\brief
|
||||
/*!\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
|
||||
/*!\brief
|
||||
* Constructs a new instance from \c Event1_info object, supporting
|
||||
* \c Curve_analysis_2 and vertical line \c index
|
||||
*
|
||||
* \c index encodes the index of event or interval depending on whether
|
||||
* this vertical line is an event-line or lies in the interval
|
||||
* \c Curve_analysis_2 and vertical line \c index
|
||||
*
|
||||
* \c index encodes the index of event or interval depending on whether
|
||||
* this vertical line is an event-line or lies in the interval
|
||||
*/
|
||||
Curve_vertical_line_1(const Event1_info& info,
|
||||
const Curve_analysis_2& ca_2, int index) :
|
||||
Base(Rep(info, ca_2, index))
|
||||
{
|
||||
CGAL_precondition(id >= 0 && index <
|
||||
this->ptr()->ca_2_.
|
||||
number_of_vertical_lines_with_event() + (is_event()? 0: 1));
|
||||
}
|
||||
const Curve_analysis_2& ca_2, int index) :
|
||||
Base(Rep(info, ca_2, index)) {
|
||||
|
||||
CGAL_precondition(id >= 0 && index <
|
||||
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:
|
||||
//!@}
|
||||
//!\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();
|
||||
}
|
||||
|
||||
//! \brief returns this vertical line supporting curve analysis
|
||||
Curve_analysis_2 get_curve_analysis_2() const
|
||||
{
|
||||
return this->ptr()->ca_2_;
|
||||
}
|
||||
|
||||
//! \brief returns this vertical line index (event or interval index)
|
||||
int get_index() const
|
||||
{
|
||||
return this->ptr()->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();
|
||||
}
|
||||
//!\name access functions
|
||||
//!@{
|
||||
|
||||
//! \brief returns the x-coordinate of the vertical line (always a finite
|
||||
//! value).
|
||||
X_coordinate_1 x() const
|
||||
{
|
||||
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()->_m_ca_2;
|
||||
}
|
||||
|
||||
//! \brief returns this vertical line index (event or interval index)
|
||||
int get_index() const
|
||||
{
|
||||
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()->_m_event_info.has_vertical_line();
|
||||
}
|
||||
|
||||
//! \brief returns number of distinct and finite intersections of a curve
|
||||
//! with a (intended) vertical line ignoring a real vertical line
|
||||
//! component of the curve at the given x-coordinate.
|
||||
int number_of_events() const
|
||||
{
|
||||
return (this->ptr()->event_info_.num_arcs());
|
||||
}
|
||||
//! \brief returns number of distinct and finite intersections of a curve
|
||||
//! with a (intended) vertical line ignoring a real vertical line
|
||||
//! component of the curve at the given x-coordinate.
|
||||
int number_of_events() const
|
||||
{
|
||||
return (this->ptr()->_m_event_info.num_arcs());
|
||||
}
|
||||
|
||||
//!\brief returns an object of type \c Xy_coordinate_2 for the j-th event
|
||||
//!
|
||||
//! \pre 0 <= j < num_of_events()
|
||||
Xy_coordinate_2 get_algebraic_real_2(int j) const
|
||||
{
|
||||
CGAL_precondition(0 <= j&&j < number_of_events());
|
||||
// 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);
|
||||
}
|
||||
//!\brief returns an object of type \c Xy_coordinate_2 for the j-th event
|
||||
//!
|
||||
//! \pre 0 <= j < num_of_events()
|
||||
Xy_coordinate_2 get_algebraic_real_2(int j) const
|
||||
{
|
||||
CGAL_precondition(0 <= j&&j < number_of_events());
|
||||
// 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()->_m_ca_2.get_polynomial_2(), j);
|
||||
}
|
||||
|
||||
//!\brief returns the number of branches of the curve connected to j-th
|
||||
//! event immediately to the left, to the right, respectively, as a pair of
|
||||
//! unsigned int ignoring vertical curve components at the given
|
||||
//! x-coordinate.
|
||||
//!
|
||||
//! \pre 0 <= j < num_of_events()
|
||||
std::pair<int, int> get_number_of_incident_branches(int j) const
|
||||
{
|
||||
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));
|
||||
}
|
||||
//!\brief returns the number of branches of the curve connected to j-th
|
||||
//! event immediately to the left, to the right, respectively, as a pair of
|
||||
//! unsigned int ignoring vertical curve components at the given
|
||||
//! x-coordinate.
|
||||
//!
|
||||
//! \pre 0 <= j < num_of_events()
|
||||
std::pair<int, int> get_number_of_incident_branches(int j) const
|
||||
{
|
||||
CGAL_precondition(0 <= j&&j < number_of_events());
|
||||
return std::make_pair(
|
||||
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
|
||||
//! approaching y=-oo from left and right. A vertical line being component
|
||||
//! of the curve is ignored.
|
||||
std::pair<int, int>
|
||||
get_number_of_branches_approaching_minus_infinity() const
|
||||
{
|
||||
int left, right, dummy;
|
||||
this->ptr()->event_info_.num_arcs_approaching_vertical_asymptote(
|
||||
left, right, dummy, dummy);
|
||||
return std::make_pair(left, right);
|
||||
}
|
||||
//!\brief returns the number of vertical asymptotes at x of the curve
|
||||
//! approaching y=-oo from left and right. A vertical line being component
|
||||
//! of the curve is ignored.
|
||||
std::pair<int, int>
|
||||
get_number_of_branches_approaching_minus_infinity() const
|
||||
{
|
||||
int left, right, dummy;
|
||||
this->ptr()->_m_event_info.num_arcs_approaching_vertical_asymptote(
|
||||
left, right, dummy, dummy);
|
||||
return std::make_pair(left, right);
|
||||
}
|
||||
|
||||
//!\brief returns the number of vertical asymptotes at x of the curve
|
||||
//! approaching y=+oo from left and right. A vertical line being component
|
||||
//! of the curve is ignored.
|
||||
std::pair<int, int>
|
||||
get_number_of_branches_approaching_plus_infinity() const
|
||||
{
|
||||
int left, right, dummy;
|
||||
this->ptr()->event_info_.num_arcs_approaching_vertical_asymptote(
|
||||
dummy, dummy, left, right);
|
||||
return std::make_pair(left, right);
|
||||
}
|
||||
//!\brief returns the number of vertical asymptotes at x of the curve
|
||||
//! approaching y=+oo from left and right. A vertical line being component
|
||||
//! of the curve is ignored.
|
||||
std::pair<int, int>
|
||||
get_number_of_branches_approaching_plus_infinity() const
|
||||
{
|
||||
int left, right, dummy;
|
||||
this->ptr()->_m_event_info.num_arcs_approaching_vertical_asymptote(
|
||||
dummy, dummy, left, right);
|
||||
return std::make_pair(left, right);
|
||||
}
|
||||
|
||||
//! \brief returns true if curve has vertical line component or curve \c f
|
||||
//! has intersection with f_y at \c x
|
||||
bool is_event() const
|
||||
{
|
||||
return this->ptr()->event_info_.is_event();
|
||||
}
|
||||
|
||||
// temporary access function (for testing)
|
||||
Event1_info get_info() const
|
||||
{
|
||||
return this->ptr()->event_info_;
|
||||
}
|
||||
//! \brief returns true if curve has vertical line component or curve \c f
|
||||
//! has intersection with f_y at \c x
|
||||
bool is_event() const
|
||||
{
|
||||
return this->ptr()->_m_event_info.is_event();
|
||||
}
|
||||
|
||||
// temporary access function (for testing)
|
||||
Event1_info get_info() const
|
||||
{
|
||||
return this->ptr()->_m_event_info;
|
||||
}
|
||||
|
||||
//!@}
|
||||
}; // class Curve_vertical_line_1
|
||||
|
||||
template <class CurveAnalysis_2, class Rep>
|
||||
std::ostream& operator<< (
|
||||
std::ostream& os,
|
||||
const CGALi::Curve_vertical_line_1<CurveAnalysis_2, Rep>& cp_line) {
|
||||
const CGALi::Curve_vertical_line_1<CurveAnalysis_2, Rep>& cp_line) {
|
||||
os << (cp_line.get_info());
|
||||
return os;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
//
|
||||
//
|
||||
// Author(s) : Eric Berberich <eric@mpi-inf.mpg.de>
|
||||
// Pavel Emeliyanenko <asm@mpi-sb.mpg.de>
|
||||
// Pavel Emeliyanenko <asm@mpi-sb.mpg.de>
|
||||
//
|
||||
// ============================================================================
|
||||
|
||||
|
|
@ -28,38 +28,38 @@ template < class AlgebraicCurveKernel_2 >
|
|||
class Xy_coordinate_2_rep {
|
||||
|
||||
public:
|
||||
// this first template argument
|
||||
typedef AlgebraicCurveKernel_2 Algebraic_curve_kernel_2;
|
||||
// this first template argument
|
||||
typedef AlgebraicCurveKernel_2 Algebraic_curve_kernel_2;
|
||||
|
||||
// myself
|
||||
// myself
|
||||
typedef Xy_coordinate_2_rep<Algebraic_curve_kernel_2> Self;
|
||||
|
||||
typedef typename Algebraic_curve_kernel_2::Curve_pair_2 Curve_pair_2;
|
||||
typedef typename Algebraic_curve_kernel_2::Curve_pair_2 Curve_pair_2;
|
||||
|
||||
typedef typename Curve_pair_2::Algebraic_curve_2 Curve_2;
|
||||
|
||||
typedef typename Curve_2::X_coordinate X_coordinate_1;
|
||||
typedef typename Curve_pair_2::Algebraic_curve_2 Curve_2;
|
||||
|
||||
typedef typename Curve_2::X_coordinate X_coordinate_1;
|
||||
|
||||
// constructors
|
||||
// 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>;
|
||||
|
|
@ -73,111 +73,89 @@ public:
|
|||
//! a supporting curve and an arcno and is valid only for finite solutions,
|
||||
//! i.e., it cannot represent points at infinity
|
||||
template <class AlgebraicCurveKernel_2,
|
||||
class Rep_ = CGALi::Xy_coordinate_2_rep<AlgebraicCurveKernel_2> >
|
||||
class Rep_ = CGALi::Xy_coordinate_2_rep<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;
|
||||
typedef AlgebraicCurveKernel_2 Algebraic_curve_kernel_2;
|
||||
|
||||
//! this instance's second template parameter
|
||||
typedef Rep_ Rep;
|
||||
typedef Rep_ Rep;
|
||||
|
||||
//! this instance itself
|
||||
typedef Xy_coordinate_2<Algebraic_curve_kernel_2, Rep> Self;
|
||||
|
||||
//! type of a curve pair
|
||||
typedef typename Algebraic_curve_kernel_2::Curve_pair_2 Curve_pair_2;
|
||||
|
||||
//! type of a curve pair
|
||||
typedef typename Algebraic_curve_kernel_2::Curve_pair_2 Curve_pair_2;
|
||||
|
||||
//! type of a curve analysis (replacement to CCPA_2)
|
||||
typedef typename Algebraic_curve_kernel_2::Curve_analysis_2
|
||||
Curve_analysis_2;
|
||||
//! type of a curve analysis (replacement to CCPA_2)
|
||||
typedef typename Algebraic_curve_kernel_2::Curve_analysis_2
|
||||
Curve_analysis_2;
|
||||
|
||||
//! type of an algabraic curve
|
||||
typedef typename Curve_pair_2::Algebraic_curve_2 Curve_2;
|
||||
//! type of an algabraic curve
|
||||
typedef typename Curve_pair_2::Algebraic_curve_2 Curve_2;
|
||||
|
||||
//! type of X_coordinate
|
||||
typedef typename Curve_2::X_coordinate X_coordinate_1;
|
||||
//! type of X_coordinate
|
||||
typedef typename Curve_2::X_coordinate X_coordinate_1;
|
||||
|
||||
//! type of curve pair analysis
|
||||
typedef typename Algebraic_curve_kernel_2::Curve_pair_analysis_2
|
||||
Curve_pair_analysis_2;
|
||||
|
||||
//! type of pair vertical line
|
||||
typedef typename Curve_pair_analysis_2::Curve_pair_vertical_line_1
|
||||
Curve_pair_vertical_line_1;
|
||||
//! type of curve pair analysis
|
||||
typedef typename Algebraic_curve_kernel_2::Curve_pair_analysis_2
|
||||
Curve_pair_analysis_2;
|
||||
|
||||
//! type of pair vertical line
|
||||
typedef typename Curve_pair_analysis_2::Curve_pair_vertical_line_1
|
||||
Curve_pair_vertical_line_1;
|
||||
|
||||
//! type of curve analysis
|
||||
typedef typename Algebraic_curve_kernel_2::Curve_analysis_2
|
||||
Curve_analysis_2;
|
||||
|
||||
//! type of vertical line
|
||||
typedef typename Curve_analysis_2::Curve_vertical_line_1
|
||||
Curve_vertical_line_1;
|
||||
//! type of curve analysis
|
||||
typedef typename Algebraic_curve_kernel_2::Curve_analysis_2
|
||||
Curve_analysis_2;
|
||||
|
||||
//! type of vertical line
|
||||
typedef typename Curve_analysis_2::Curve_vertical_line_1
|
||||
Curve_vertical_line_1;
|
||||
|
||||
//! 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;
|
||||
std::vector<Curve_2> parts_of_f, parts_of_g, common;
|
||||
Algebraic_curve_kernel_2 ak_2;
|
||||
|
||||
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);
|
||||
|
||||
// ATTENTION: here the cache must be used !!
|
||||
if (static_cast< int >(parts_of_f.size()) == 2) {
|
||||
std::back_inserter(parts_of_f), std::back_inserter(parts_of_g),
|
||||
std::back_inserter(common))) {
|
||||
CGAL_assertion((parts_of_f.size() == 1 ||
|
||||
parts_of_g.size() == 1) && common.size() == 1);
|
||||
// ATTENTION: here the cache must be used !!
|
||||
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,58 +166,46 @@ 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
|
||||
*
|
||||
* \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;
|
||||
Curve_analysis_2 ca(curve);
|
||||
typename Curve_analysis_2::Curve_vertical_line_1 v =
|
||||
ca.vertical_line_for_x(x);
|
||||
);
|
||||
int i = -1;
|
||||
Curve_analysis_2 ca(curve);
|
||||
typename Curve_analysis_2::Curve_vertical_line_1 v =
|
||||
ca.vertical_line_for_x(x);
|
||||
);
|
||||
CGAL_precondition(arcno < v.number_of_events());
|
||||
}
|
||||
|
||||
/*!\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,204 +229,105 @@ 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 ?
|
||||
* directly ?
|
||||
*/
|
||||
template < class Point_2 >
|
||||
CGAL::Comparison_result compare_x(const Point_2& q) const {
|
||||
if (this->is_identical(q)) {
|
||||
CGAL::Comparison_result compare_x(const Self& q) const
|
||||
{
|
||||
if(this->is_identical(q)) {
|
||||
return CGAL::EQUAL;
|
||||
}
|
||||
Algebraic_curve_kernel_2 ak_2;
|
||||
Algebraic_curve_kernel_2 ak_2;
|
||||
return ak_2.compare_x_2_object()(this->x(), q.x());
|
||||
}
|
||||
|
||||
/*!\brief
|
||||
* compares \c *this with \c q lexicographically
|
||||
*/
|
||||
template < class Point_2 >
|
||||
CGAL::Comparison_result compare_xy(const Point_2& q,
|
||||
bool equal_x = false) const
|
||||
CGAL::Comparison_result compare_xy(const Self& q,
|
||||
bool equal_x = false) const
|
||||
{
|
||||
if (this->is_identical(q)) {
|
||||
if(this->is_identical(q)) {
|
||||
return CGAL::EQUAL;
|
||||
}
|
||||
if (!equal_x) {
|
||||
if(!equal_x) {
|
||||
CGAL::Comparison_result c = this->compare_x(q);
|
||||
if (c != CGAL::EQUAL) {
|
||||
CGAL_assertion(c == CGAL::SMALLER || c == CGAL::LARGER);
|
||||
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(!f.is_identical(g)) { // common parts of curves?
|
||||
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;
|
||||
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());
|
||||
// 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());
|
||||
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;
|
||||
vline.get_event_of_curve(1, q.arcno()));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//!@}
|
||||
|
||||
public:
|
||||
//!\name Reconstructing functions
|
||||
//!@{
|
||||
|
|
@ -478,37 +345,37 @@ public:
|
|||
* \pre pair must be a decomposition of curve()
|
||||
*/
|
||||
void simplify_by(const Curve_pair_analysis_2& pair) const
|
||||
{
|
||||
typedef typename Algebraic_curve_kernel_2::Polynomial_2 Poly_2;
|
||||
typename Algebraic_curve_kernel_2::NiX2CGAL_converter cvt;
|
||||
typedef typename CGAL::Polynomial_traits_d<Poly_2>::Total_degree
|
||||
Total_degree;
|
||||
|
||||
CGAL_precondition_code(
|
||||
typename Curve_2::Poly_d mult =
|
||||
pair.get_curve_analysis(0).get_polynomial_2().f() *
|
||||
pair.get_curve_analysis(1).get_polynomial_2().f();
|
||||
Total_degree total_degree;
|
||||
{
|
||||
typedef typename Algebraic_curve_kernel_2::Polynomial_2 Poly_2;
|
||||
typename Algebraic_curve_kernel_2::NiX2CGAL_converter cvt;
|
||||
typedef typename CGAL::Polynomial_traits_d<Poly_2>::Total_degree
|
||||
Total_degree;
|
||||
|
||||
CGAL_precondition_code(
|
||||
typename Curve_2::Poly_d mult =
|
||||
pair.get_curve_analysis(0).get_polynomial_2().f() *
|
||||
pair.get_curve_analysis(1).get_polynomial_2().f();
|
||||
Total_degree total_degree;
|
||||
);
|
||||
// common parts
|
||||
CGAL_precondition(NiX::resultant(mult, curve().f()).is_zero());
|
||||
// full parts
|
||||
CGAL_precondition(mult.degree() == curve().f().degree());
|
||||
CGAL_precondition(total_degree(cvt(mult)) ==
|
||||
total_degree(cvt(curve().f())));
|
||||
total_degree(cvt(curve().f())));
|
||||
|
||||
const Curve_pair_vertical_line_1& cpv_line =
|
||||
pair.vertical_line_for_x(x());
|
||||
const Curve_pair_vertical_line_1& cpv_line =
|
||||
pair.vertical_line_for_x(x());
|
||||
// # of arcs must match
|
||||
CGAL_precondition_code(
|
||||
const Curve_vertical_line_1& cv_line =
|
||||
Curve_analysis_2(curve()).vertical_line_for_x(x());
|
||||
);
|
||||
CGAL_precondition_code(
|
||||
const Curve_vertical_line_1& cv_line =
|
||||
Curve_analysis_2(curve()).vertical_line_for_x(x());
|
||||
);
|
||||
CGAL_precondition(cpv_line.number_of_events() ==
|
||||
cv_line.number_of_events());
|
||||
cv_line.number_of_events());
|
||||
|
||||
int cid = 0;
|
||||
std::pair<int, int> p = cpv_line.get_curves_at_event(arcno());
|
||||
std::pair<int, int> p = cpv_line.get_curves_at_event(arcno());
|
||||
|
||||
if(p.first != -1 && p.second != -1) {
|
||||
// both curves involved: choose simpler one
|
||||
|
|
@ -517,20 +384,20 @@ public:
|
|||
// the point from the composed curved (also including this vertical
|
||||
// line). Therefore, the old arc number is also valid in the curve
|
||||
// pair.
|
||||
Total_degree total_degree;
|
||||
Poly_2 ff = cvt(pair.get_curve_analysis(0).get_polynomial_2().f()),
|
||||
gg = cvt(pair.get_curve_analysis(1).get_polynomial_2().f());
|
||||
if(total_degree(ff) > total_degree(gg))
|
||||
Total_degree total_degree;
|
||||
Poly_2 ff = cvt(pair.get_curve_analysis(0).get_polynomial_2().f()),
|
||||
gg = cvt(pair.get_curve_analysis(1).get_polynomial_2().f());
|
||||
if(total_degree(ff) > total_degree(gg))
|
||||
cid = 1;
|
||||
} else
|
||||
cid = (p.first == -1 ? 1 : 0);
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in New Issue