Modified the less functor to operate in two modes: compare_right and

compare_at. The first one is the old operation mode. The second one
is used in the FirstPass() function to catch degenerate cases.
A global variable is currently used to allow modifying the operation
mode.
This commit is contained in:
Tali Zvi 2003-02-19 21:26:55 +00:00
parent aeca76db47
commit 4a91c49e1d
2 changed files with 33 additions and 5 deletions

View File

@ -29,6 +29,8 @@
CGAL_BEGIN_NAMESPACE
int g_compare_func = 1;
template <class Point, class SweepLineTraits_2>
class Point_less_functor
{
@ -89,6 +91,7 @@ private:
};
#endif
template <class SweepLineTraits_2, class Subcurve>
class Status_line_curve_less_functor
{
@ -96,11 +99,34 @@ public:
typedef SweepLineTraits_2 Traits;
typedef typename Traits::Point_2 Point_2;
typedef typename Traits::X_curve_2 X_curve_2;
//typedef Sweep_line_subcurve<Traits> Subcurve;
typedef bool (Status_line_curve_less_functor::*func)
(const Subcurve*, const Subcurve*) const;
Status_line_curve_less_functor(Traits *traits) : m_traits(traits) {}
Status_line_curve_less_functor(Traits *traits) : m_traits(traits) {
m_compare[0] = &Status_line_curve_less_functor::compare_at;
m_compare[1] = &Status_line_curve_less_functor::compare_right;
}
bool operator()(const Subcurve* c1, const Subcurve* c2) const {
bool operator()(const Subcurve* c1, const Subcurve* c2) const {
return (this->*m_compare[g_compare_func])(c1, c2);
}
func m_compare[2];
bool compare_at(const Subcurve* c1, const Subcurve* c2) const
{
const Point_2 *p = c1->getReferencePoint();
Comparison_result r =
m_traits->curve_compare_at_x(c1->getCurve(),
c2->getCurve(),
*p);
if ( r == SMALLER) {
return true;
}
return false;
}
bool compare_right(const Subcurve* c1, const Subcurve* c2) const {
const Point_2 *p = c1->getReferencePoint();
#if 0
std::cout << "\t\tComparing between:" << *p << "\n"

View File

@ -921,6 +921,7 @@ FirstPass()
EventCurveIter rightIter = m_currentEvent->rightCurvesBegin();
m_currentPos = m_sweepLinePos;
g_compare_func = 0;
while ( rightIter != m_currentEvent->rightCurvesEnd())
{
// if the point is not an end point, skip it
@ -929,7 +930,7 @@ FirstPass()
continue;
}
#if 1
#if 0
// improve here
StatusLineIter slIter = m_statusLine->begin();
while ( slIter != m_statusLine->end() )
@ -980,6 +981,7 @@ FirstPass()
#endif // 1
++rightIter;
}
g_compare_func = 1;
SL_DEBUG(m_currentEvent->Print();)
SL_DEBUG(std::cout << "First pass - done\n" ;)
@ -1619,7 +1621,7 @@ inline bool
Sweep_line_tight_2<CurveInputIterator,SweepLineTraits_2,SweepEvent,CurveWrap>::
DoCurvesOverlap(Subcurve *c1, Subcurve *c2)
{
#if 0
#if 1
// improve here...
if ( m_traits->curve_compare_at_x_right(c1->getCurve(),
c2->getCurve(),