Used traits predicate instead of '==' operator

This commit is contained in:
Efi Fogel 2003-04-09 18:53:35 +00:00
parent 08165872d2
commit 39c8a50a0b
2 changed files with 77 additions and 71 deletions

View File

@ -229,7 +229,7 @@ public:
const X_curve_2_iterator & end,
Change_notification * en = NULL)
{
PointLessFunctor event_queue_pred(traits);
PointLessFunctor event_queue_pred(traits);
Event_queue event_queue(event_queue_pred);
init_for_insert(begin, end, event_queue);
@ -782,19 +782,19 @@ private:
// look for the interection point in the queue. if does not exist,
// add it. if exists, merge it with the existing one (add the curve)
Event_queue_iterator edge_point =
Event_queue_iterator edge_point =
event_queue.find( traits->curve_source(cv) );
if (edge_point == event_queue.end() ||
edge_point->second.get_point() != curr_point_plus->second) {
Point_node new_ix =
Point_node new_ix =
Point_node(cv_node, curr_point_plus->second, traits );
event_queue.insert(Event_queue_value_type(traits->curve_source(cv),
new_ix));
}
else
else {
edge_point->second.add_curve(cv_node);
}
// same as above for the curve's target
edge_point = event_queue.find( traits->curve_target(cv) );
@ -820,12 +820,15 @@ private:
//-----------------------------------------------------------------------------
// Member Function Definitions
//-----------------------------------------------------------------------------
/*! A parameter-less constructor.
*/
template < class Dcel, class Traits >
Planar_map_2< Dcel, Traits >::Planar_map_2()
{
traits = new Traits_wrap();
use_delete_traits = true;
#ifndef CGAL_NO_PM_DEFAULT_POINT_LOCATION
pl = new Pm_default_point_location<Self>;
use_delete_pl = true;
@ -835,12 +838,13 @@ Planar_map_2< Dcel, Traits >::Planar_map_2()
"No default point location is defined; you must supply one.");
#endif
bb=init_default_bounding_box((Traits*)traits);
use_delete_bb=true;
bb->init(*this,*traits);
bb = init_default_bounding_box((Traits*)traits);
use_delete_bb = true;
bb->init(*this, *traits);
}
//-----------------------------------------------------------------------------
/*! A constructor given a point-location parameter.
*/
template < class Dcel, class Traits >
Planar_map_2< Dcel, Traits >::
Planar_map_2(typename Planar_map_2<Dcel, Traits>::Point_location_base * pl_ptr)
@ -850,19 +854,22 @@ Planar_map_2(typename Planar_map_2<Dcel, Traits>::Point_location_base * pl_ptr)
pl = pl_ptr;
use_delete_pl = false;
pl->init(*this,*traits);
pl->init(*this, *traits);
bb = init_default_bounding_box((Traits*)traits);
use_delete_bb = true;
bb->init(*this,*traits);
bb->init(*this, *traits);
}
//-----------------------------------------------------------------------------
/*! A constructor given a copy traits, point-location, and
* Bounding-box parameters.
*/
template < class Dcel, class Traits >
Planar_map_2< Dcel, Traits >::
Planar_map_2(
const typename Planar_map_2< Dcel, Traits >::Traits & tr_,
typename Planar_map_2< Dcel, Traits >::Point_location_base * pl_ptr,
typename Planar_map_2< Dcel, Traits >::Bounding_box_base * bb_ptr )
const typename Planar_map_2<Dcel, Traits>::Traits & tr_,
typename Planar_map_2<Dcel, Traits>::Point_location_base * pl_ptr,
typename Planar_map_2<Dcel, Traits>::Bounding_box_base * bb_ptr)
{
traits = new Traits_wrap(tr_);
use_delete_traits = true;
@ -882,7 +889,7 @@ Planar_map_2(
{
pl = pl_ptr;
use_delete_pl = false;
pl->init(*this,*traits);
pl->init(*this, *traits);
}
if (bb_ptr == NULL)
@ -898,13 +905,16 @@ Planar_map_2(
bb->init(*this,*traits);
}
}
//-----------------------------------------------------------------------------
/*! A constructor given a copy traits wrap, point-location, and
* Bounding-box parameters.
*/
template < class Dcel, class Traits >
Planar_map_2< Dcel, Traits >::
Planar_map_2(
typename Planar_map_2< Dcel, Traits >::Traits_wrap *tr_ptr,
typename Planar_map_2< Dcel, Traits >::Point_location_base *pl_ptr,
typename Planar_map_2< Dcel, Traits >::Bounding_box_base *bb_ptr )
typename Planar_map_2< Dcel, Traits >::Traits_wrap * tr_ptr,
typename Planar_map_2< Dcel, Traits >::Point_location_base * pl_ptr,
typename Planar_map_2< Dcel, Traits >::Bounding_box_base * bb_ptr )
{
if (tr_ptr == NULL)
{
@ -949,15 +959,13 @@ Planar_map_2(
}
}
//template < class Dcel, class Traits, class InputIterator >
//Planar_map_2< Dcel, Traits >::
//Planar_map_2(InputIterator curves_begin, InputIterator curves_end)
//{}
//-----------------------------------------------------------------------------
/*! A copy constructor.
* \todo get rid of the cast. Instead implement a copy constructor and a clone
* operation for the various point location strategies.
*/
template < class Dcel, class Traits >
Planar_map_2< Dcel, Traits >::
Planar_map_2(const Planar_map_2< Dcel, Traits >& pm )
Planar_map_2(const Planar_map_2<Dcel, Traits> & pm)
{
// doing the same as Planar_map_2(pm.get_traits(),pm.get_point_location(),
// pm.get_point_bbox());
@ -1859,8 +1867,8 @@ update_subdivision(Point_node& point_node,
// if the point is the source of the curve, we ignore it for now.
// the curve will be handled when we get to its target
if ( traits->curve_source(cv_iter->get_curve()) ==
point_node.get_point().point()) {
if (traits->point_is_same(traits->curve_source(cv_iter->get_curve()),
point_node.get_point().point())) {
continue;
}
@ -1890,20 +1898,22 @@ update_subdivision(Point_node& point_node,
}
// Update the vertex handle of each point, for future use
if (h->source()->point() == cv_iter->get_point().point())
if (traits->point_is_same(h->source()->point(),
cv_iter->get_point().point()))
cv_iter->get_point().set_vertex(h->source());
else if (h->target()->point() ==
cv_iter->get_point().point())
else if (traits->point_is_same(h->target()->point(),
cv_iter->get_point().point()))
cv_iter->get_point().set_vertex(h->target());
if (h->source()->point() == point_node.get_point().point())
if (traits->point_is_same(h->source()->point(),
point_node.get_point().point()))
point_node.get_point().set_vertex(h->source());
else if (h->target()->point() == point_node.get_point().point())
else if (traits->point_is_same(h->target()->point(),
point_node.get_point().point()))
point_node.get_point().set_vertex(h->target());
}
}
CGAL_END_NAMESPACE
#endif // CGAL_PLANAR_MAP_2_H
// EOF
#endif

View File

@ -28,6 +28,7 @@
#include <CGAL/Handle_for.h>
#include <CGAL/Sweep_line_2/Point_plus_handle.h>
CGAL_BEGIN_NAMESPACE
template <class SweepLineTraits_2,
@ -41,38 +42,34 @@ class Pm_curve_node : public Handle_for< typename SweepLineTraits_2::X_curve >
typedef Point_plus_ Point_plus;
public:
public:
Pm_curve_node(const X_curve& cv, const Point_plus& p, Traits* traits_) :
Handle_for_curve(cv), m_point(p), m_traits(traits_)
{}
~Pm_curve_node() {}
bool operator==(const Pm_curve_node& cv_node) const {
bool operator==(const Pm_curve_node & cv_node) const {
return *ptr() == *(cv_node.ptr());
}
bool operator!=(const Pm_curve_node& cv_node) const {
bool operator!=(const Pm_curve_node & cv_node) const {
return !operator==(cv_node);
}
const X_curve& get_curve() const {
return *ptr();
}
Point_plus& get_point() {
return m_point;
}
Self& operator=(const Self &cv_node) {
const X_curve & get_curve() const { return *ptr(); }
Point_plus & get_point() { return m_point; }
Self & operator=(const Self & cv_node) {
Handle_for_curve::operator=(cv_node);
return *this;
return *this;
}
private:
Point_plus m_point;
Traits *m_traits;
private:
Point_plus m_point;
Traits * m_traits;
};
@ -87,7 +84,7 @@ template <class SweepLineTraits_2,
class Pm_point_node
{
public:
public:
typedef Pm_point_node Self;
typedef SweepLineTraits_2 Traits;
@ -111,29 +108,29 @@ class Pm_point_node
}
Pm_point_node(const Curve_node_& cv,
const Point_plus& ref_point,
Traits *traits_) :
const Point_plus & ref_point,
Traits * traits_) :
m_intersect_p(ref_point), m_traits(traits_) {
m_curves.push_back(cv);
}
void add_curve(Curve_node_ &cv) {
void add_curve(Curve_node_ & cv) {
m_curves.push_back(cv);
}
Point_plus& get_point() { return m_intersect_p; }
const Point_plus& get_point() const { return m_intersect_p; }
Point_plus & get_point() { return m_intersect_p; }
const Point_plus & get_point() const { return m_intersect_p; }
Curve_node_iterator curves_begin() { return m_curves.begin(); }
Curve_node_iterator curves_end() { return m_curves.end(); }
Curve_node_iterator curves_begin() { return m_curves.begin(); }
Curve_node_iterator curves_end() { return m_curves.end(); }
Curve_node_const_iterator curves_begin() const { return m_curves.begin(); }
Curve_node_const_iterator curves_end() const { return m_curves.end(); }
Curve_node_const_iterator curves_begin() const { return m_curves.begin(); }
Curve_node_const_iterator curves_end() const { return m_curves.end(); }
protected:
Point_plus m_intersect_p;
Curve_node_container m_curves;
Traits *m_traits;
Point_plus m_intersect_p;
Curve_node_container m_curves;
Traits *m_traits;
};
@ -145,15 +142,14 @@ class Pm_less_point_xy
Pm_less_point_xy(Traits *traits_) : m_traits(traits_) {}
inline bool operator()(const Point& p1, const Point& p2) const
inline bool operator()(const Point & p1, const Point & p2) const
{
return (m_traits->compare_xy(p1,p2) == SMALLER);
return (m_traits->compare_xy(p1, p2) == SMALLER);
}
private:
Traits *m_traits;
private:
Traits * m_traits;
};
CGAL_END_NAMESPACE
#endif