Common reformatting of the _pair classes (oh joy...).

This commit is contained in:
Sylvain Pion 2008-08-20 13:49:31 +00:00
parent 49549ded08
commit f5b031be68
10 changed files with 194 additions and 539 deletions

View File

@ -49,42 +49,6 @@ struct Pointlist_2_ {
~Pointlist_2_() ; ~Pointlist_2_() ;
}; };
template <class K>
class Triangle_2_Triangle_2_pair {
public:
enum Intersection_results {NO_INTERSECTION, POINT, SEGMENT, TRIANGLE, POLYGON};
Triangle_2_Triangle_2_pair() ;
Triangle_2_Triangle_2_pair(
typename K::Triangle_2 const *trian1,
typename K::Triangle_2 const *trian2) ;
~Triangle_2_Triangle_2_pair() {}
Intersection_results intersection_type() const;
bool intersection(typename K::Point_2 &result) const;
bool intersection(typename K::Segment_2 &result) const;
bool intersection(typename K::Triangle_2 &result) const;
bool intersection(/*Polygon_2<R> &result*/) const;
int vertex_count() const;
typename K::Point_2 vertex(int i) const;
protected:
typename K::Triangle_2 const* _trian1;
typename K::Triangle_2 const * _trian2;
mutable bool _known;
mutable Intersection_results _result;
mutable Pointlist_2_<K> _pointlist;
};
// template <class R>
// inline bool do_intersect(
// const Triangle_2<R> &p1,
// const Triangle_2<R> &p2)
// {
// typedef Triangle_2_Triangle_2_pair<R> pair_t;
// pair_t pair(&p1, &p2);
// return pair.intersection_type() != pair_t::NO_INTERSECTION;
// }
template <class K> template <class K>
@ -191,24 +155,30 @@ void _cut_off(Pointlist_2_<K> &list,
list.size += add; list.size += add;
} }
template <class K>
Triangle_2_Triangle_2_pair<K>::
Triangle_2_Triangle_2_pair()
{
_trian1 = 0;
_trian2 = 0;
_known = false;
}
template <class K> template <class K>
Triangle_2_Triangle_2_pair<K>:: class Triangle_2_Triangle_2_pair {
Triangle_2_Triangle_2_pair(typename K::Triangle_2 const *trian1, public:
enum Intersection_results {NO_INTERSECTION, POINT, SEGMENT, TRIANGLE, POLYGON};
Triangle_2_Triangle_2_pair(typename K::Triangle_2 const *trian1,
typename K::Triangle_2 const *trian2) typename K::Triangle_2 const *trian2)
{ : _trian1(trian1), _trian2(trian2), _known(false) {}
_trian1 = trian1;
_trian2 = trian2; Intersection_results intersection_type() const;
_known = false;
} typename K::Point_2 intersection_point() const;
typename K::Segment_2 intersection_segment() const;
typename K::Triangle_2 intersection_triangle() const;
bool intersection(/*Polygon_2<R> &result*/) const;
int vertex_count() const;
typename K::Point_2 vertex(int i) const;
protected:
typename K::Triangle_2 const* _trian1;
typename K::Triangle_2 const * _trian2;
mutable bool _known;
mutable Intersection_results _result;
mutable Pointlist_2_<K> _pointlist;
};
template <class K> template <class K>
typename Triangle_2_Triangle_2_pair<K>::Intersection_results typename Triangle_2_Triangle_2_pair<K>::Intersection_results
@ -310,47 +280,38 @@ Triangle_2_Triangle_2_pair<K>::vertex(int n) const
} }
template <class K> template <class K>
bool typename K::Triangle_2
Triangle_2_Triangle_2_pair<K>::intersection( Triangle_2_Triangle_2_pair<K>::intersection_triangle() const
typename K::Triangle_2 &result) const
{ {
typedef typename K::Triangle_2 Triangle_2; typedef typename K::Triangle_2 Triangle_2;
if (!_known) if (!_known)
intersection_type(); intersection_type();
if (_result != TRIANGLE) CGAL_kernel_assertion(_result == TRIANGLE);
return false; return Triangle_2(_pointlist.first->point,
result = Triangle_2(_pointlist.first->point,
_pointlist.first->next->point, _pointlist.first->next->point,
_pointlist.first->next->next->point); _pointlist.first->next->next->point);
return true;
} }
template <class K> template <class K>
bool typename K::Segment_2
Triangle_2_Triangle_2_pair<K>::intersection( Triangle_2_Triangle_2_pair<K>::intersection_segment() const
typename K::Segment_2 &seg) const
{ {
typedef typename K::Segment_2 Segment_2; typedef typename K::Segment_2 Segment_2;
if (!_known) if (!_known)
intersection_type(); intersection_type();
if (_result != SEGMENT) CGAL_kernel_assertion(_result == SEGMENT);
return false; return Segment_2(_pointlist.first->point,
seg = Segment_2(_pointlist.first->point,
_pointlist.first->next->point); _pointlist.first->next->point);
return true;
} }
template <class K> template <class K>
bool typename K::Point_2
Triangle_2_Triangle_2_pair<K>::intersection( Triangle_2_Triangle_2_pair<K>::intersection_point() const
typename K::Point_2 &pt) const
{ {
if (!_known) if (!_known)
intersection_type(); intersection_type();
if (_result != POINT) CGAL_kernel_assertion(_result == POINT);
return false; return _pointlist.first->point;
pt = _pointlist.first->point;
return true;
} }
@ -367,21 +328,12 @@ intersection(const typename K::Triangle_2 &tr1,
case is_t::NO_INTERSECTION: case is_t::NO_INTERSECTION:
default: default:
return Object(); return Object();
case is_t::POINT: { case is_t::POINT:
typename K::Point_2 pt; return make_object(ispair.intersection_point());
ispair.intersection(pt); case is_t::SEGMENT:
return make_object(pt); return make_object(ispair.intersection_segment());
} case is_t::TRIANGLE:
case is_t::SEGMENT: { return make_object(ispair.intersection_triangle());
typename K::Segment_2 iseg;
ispair.intersection(iseg);
return make_object(iseg);
}
case is_t::TRIANGLE: {
typename K::Triangle_2 itr;
ispair.intersection(itr);
return make_object(itr);
}
case is_t::POLYGON: { case is_t::POLYGON: {
typedef std::vector<typename K::Point_2> Container; typedef std::vector<typename K::Point_2> Container;
Container points(ispair.vertex_count()); Container points(ispair.vertex_count());

View File

@ -40,15 +40,18 @@ template <class K>
class Line_2_Iso_rectangle_2_pair { class Line_2_Iso_rectangle_2_pair {
public: public:
enum Intersection_results {NO_INTERSECTION, POINT, SEGMENT}; enum Intersection_results {NO_INTERSECTION, POINT, SEGMENT};
Line_2_Iso_rectangle_2_pair() ; Line_2_Iso_rectangle_2_pair(typename K::Line_2 const *line,
Line_2_Iso_rectangle_2_pair(typename K::Line_2 const *pt, typename K::Iso_rectangle_2 const *iso)
typename K::Iso_rectangle_2 const *iso); : _known(false),
~Line_2_Iso_rectangle_2_pair() {} _ref_point(line->point()),
_dir(line->direction().to_vector()),
_isomin((iso->min)()),
_isomax((iso->max)()) {}
Intersection_results intersection_type() const; Intersection_results intersection_type() const;
bool intersection(typename K::Point_2 &result) const; typename K::Point_2 intersection_point() const;
bool intersection(typename K::Segment_2 &result) const; typename K::Segment_2 intersection_segment() const;
protected: protected:
mutable bool _known; mutable bool _known;
mutable Intersection_results _result; mutable Intersection_results _result;
@ -78,24 +81,6 @@ inline bool do_intersect(const typename K::Iso_rectangle_2 &p2,
} }
template <class K>
Line_2_Iso_rectangle_2_pair<K>::
Line_2_Iso_rectangle_2_pair()
{
_known = false;
}
template <class K>
Line_2_Iso_rectangle_2_pair<K>::
Line_2_Iso_rectangle_2_pair(typename K::Line_2 const *line,
typename K::Iso_rectangle_2 const *iso)
: _known(false),
_ref_point(line->point()),
_dir(line->direction().to_vector()),
_isomin((iso->min)()),
_isomax((iso->max)())
{}
template <class K> template <class K>
typename Line_2_Iso_rectangle_2_pair<K>::Intersection_results typename Line_2_Iso_rectangle_2_pair<K>::Intersection_results
@ -167,36 +152,32 @@ Line_2_Iso_rectangle_2_pair<K>::intersection_type() const
template <class K> template <class K>
bool typename K::Point_2
Line_2_Iso_rectangle_2_pair<K>:: Line_2_Iso_rectangle_2_pair<K>::
intersection(typename K::Point_2 &result) const intersection_point() const
{ {
typename K::Construct_translated_point_2 translated_point; typename K::Construct_translated_point_2 translated_point;
typename K::Construct_scaled_vector_2 construct_scaled_vector; typename K::Construct_scaled_vector_2 construct_scaled_vector;
if (!_known) if (!_known)
intersection_type(); intersection_type();
if (_result != POINT) CGAL_kernel_assertion(_result == POINT);
return false; return translated_point(_ref_point, construct_scaled_vector(_dir, _min));
result = translated_point(_ref_point, construct_scaled_vector(_dir, _min));
return true;
} }
template <class K> template <class K>
bool typename K::Segment_2
Line_2_Iso_rectangle_2_pair<K>:: Line_2_Iso_rectangle_2_pair<K>::
intersection(typename K::Segment_2 &result) const intersection_segment() const
{ {
typename K::Construct_segment_2 construct_segment_2; typename K::Construct_segment_2 construct_segment_2;
typename K::Construct_translated_point_2 translated_point; typename K::Construct_translated_point_2 translated_point;
typename K::Construct_scaled_vector_2 construct_scaled_vector; typename K::Construct_scaled_vector_2 construct_scaled_vector;
if (!_known) if (!_known)
intersection_type(); intersection_type();
if (_result != SEGMENT) CGAL_kernel_assertion(_result == SEGMENT);
return false; return construct_segment_2(translated_point(_ref_point, construct_scaled_vector(_dir,_min)),
result = construct_segment_2(translated_point(_ref_point, construct_scaled_vector(_dir,_min)),
translated_point(_ref_point, construct_scaled_vector(_dir,_max))); translated_point(_ref_point, construct_scaled_vector(_dir,_max)));
return true;
} }
@ -214,16 +195,10 @@ intersection(const typename K::Line_2 &line,
case is_t::NO_INTERSECTION: case is_t::NO_INTERSECTION:
default: default:
return Object(); return Object();
case is_t::POINT: { case is_t::POINT:
typename K::Point_2 ipt; return construct_object(ispair.intersection_point());
ispair.intersection(ipt); case is_t::SEGMENT:
return construct_object(ipt); return construct_object(ispair.intersection_segment());
}
case is_t::SEGMENT: {
typename K::Segment_2 iseg;
ispair.intersection(iseg);
return construct_object(iseg);
}
} }
} }
@ -237,21 +212,9 @@ intersection(const typename K::Iso_rectangle_2 &iso,
return CGALi::intersection(line, iso, k); return CGALi::intersection(line, iso, k);
} }
template <class K>
class Iso_rectangle_2_Line_2_pair
: public Line_2_Iso_rectangle_2_pair<K> {
public:
Iso_rectangle_2_Line_2_pair(
typename K::Iso_rectangle_2 const *iso,
typename K::Line_2 const *line) :
Line_2_Iso_rectangle_2_pair<K>(line, iso) {}
};
} // namespace CGALi } // namespace CGALi
template <class K> template <class K>
inline bool do_intersect( inline bool do_intersect(
const Line_2<K> &p1, const Line_2<K> &p1,

View File

@ -42,15 +42,14 @@ template <class K>
class Line_2_Triangle_2_pair { class Line_2_Triangle_2_pair {
public: public:
enum Intersection_results {NO_INTERSECTION, POINT, SEGMENT}; enum Intersection_results {NO_INTERSECTION, POINT, SEGMENT};
Line_2_Triangle_2_pair() ;
Line_2_Triangle_2_pair(typename K::Line_2 const *line, Line_2_Triangle_2_pair(typename K::Line_2 const *line,
typename K::Triangle_2 const *trian); typename K::Triangle_2 const *trian)
~Line_2_Triangle_2_pair() {} : _line(line), _trian(trian), _known(false) {}
Intersection_results intersection_type() const; Intersection_results intersection_type() const;
bool intersection(typename K::Point_2 &result) const; typename K::Point_2 intersection_point() const;
bool intersection(typename K::Segment_2 &result) const; typename K::Segment_2 intersection_segment() const;
protected: protected:
typename K::Line_2 const*_line; typename K::Line_2 const*_line;
typename K::Triangle_2 const * _trian; typename K::Triangle_2 const * _trian;
@ -82,25 +81,6 @@ do_intersect(const typename K::Triangle_2 &p2,
return CGALi::do_intersect(p1, p2, k); return CGALi::do_intersect(p1, p2, k);
} }
template <class K>
Line_2_Triangle_2_pair<K>::
Line_2_Triangle_2_pair()
{
_known = false;
_line = 0;
_trian = 0;
}
template <class K>
Line_2_Triangle_2_pair<K>::
Line_2_Triangle_2_pair(typename K::Line_2 const *line,
typename K::Triangle_2 const *trian)
{
_known = false;
_line = line;
_trian = trian;
}
template <class K> template <class K>
typename Line_2_Triangle_2_pair<K>::Intersection_results typename Line_2_Triangle_2_pair<K>::Intersection_results
Line_2_Triangle_2_pair<K>::intersection_type() const Line_2_Triangle_2_pair<K>::intersection_type() const
@ -154,30 +134,26 @@ if (l.oriented_side(_trian->vertex(2)) == ON_POSITIVE_SIDE) {
template <class K> template <class K>
bool typename K::Point_2
Line_2_Triangle_2_pair<K>:: Line_2_Triangle_2_pair<K>::
intersection(typename K::Point_2 &result) const intersection_point() const
{ {
if (!_known) if (!_known)
intersection_type(); intersection_type();
if (_result != POINT) CGAL_kernel_assertion(_result == POINT);
return false; return _intersection_point;
result = _intersection_point;
return true;
} }
template <class K> template <class K>
bool typename K::Segment_2
Line_2_Triangle_2_pair<K>:: Line_2_Triangle_2_pair<K>::
intersection(typename K::Segment_2 &result) const intersection_segment() const
{ {
typedef typename K::Segment_2 Segment_2; typedef typename K::Segment_2 Segment_2;
if (!_known) if (!_known)
intersection_type(); intersection_type();
if (_result != SEGMENT) CGAL_kernel_assertion(_result == SEGMENT);
return false; return Segment_2(_intersection_point, _other_point);
result = Segment_2(_intersection_point, _other_point);
return true;
} }
@ -195,16 +171,10 @@ intersection(const typename K::Line_2 &line,
case is_t::NO_INTERSECTION: case is_t::NO_INTERSECTION:
default: default:
return Object(); return Object();
case is_t::POINT: { case is_t::POINT:
typename K::Point_2 pt; return make_object(ispair.intersection_point());
ispair.intersection(pt); case is_t::SEGMENT:
return make_object(pt); return make_object(ispair.intersection_segment());
}
case is_t::SEGMENT: {
typename K::Segment_2 iseg;
ispair.intersection(iseg);
return make_object(iseg);
}
} }
} }
@ -219,17 +189,6 @@ intersection(const typename K::Triangle_2 &tr,
return intersection(line, tr, k); return intersection(line, tr, k);
} }
template <class K>
class Triangle_2_Line_2_pair
: public Line_2_Triangle_2_pair<K> {
public:
Triangle_2_Line_2_pair(
typename K::Triangle_2 const *trian,
typename K::Line_2 const *line) :
Line_2_Triangle_2_pair<K>(line, trian) {}
};
} // namespace CGALi } // namespace CGALi
template <class K> template <class K>

View File

@ -41,14 +41,13 @@ template <class K>
class Point_2_Triangle_2_pair { class Point_2_Triangle_2_pair {
public: public:
enum Intersection_results {NO_INTERSECTION, POINT}; enum Intersection_results {NO_INTERSECTION, POINT};
Point_2_Triangle_2_pair() ;
Point_2_Triangle_2_pair(typename K::Point_2 const *pt, Point_2_Triangle_2_pair(typename K::Point_2 const *pt,
typename K::Triangle_2 const *trian); typename K::Triangle_2 const *trian)
~Point_2_Triangle_2_pair() {} : _pt(pt), _trian(trian), _known(false) {}
Intersection_results intersection_type() const; Intersection_results intersection_type() const;
bool intersection(typename K::Point_2 &result) const; typename K::Point_2 intersection_point() const;
protected: protected:
typename K::Point_2 const * _pt; typename K::Point_2 const * _pt;
typename K::Triangle_2 const * _trian; typename K::Triangle_2 const * _trian;
@ -67,6 +66,7 @@ inline bool do_intersect(const typename K::Point_2 &p1,
pair_t pair(&p1, &p2); pair_t pair(&p1, &p2);
return pair.intersection_type() != pair_t::NO_INTERSECTION; return pair.intersection_type() != pair_t::NO_INTERSECTION;
} }
template <class K> template <class K>
inline bool do_intersect(const typename K::Triangle_2 &p2, inline bool do_intersect(const typename K::Triangle_2 &p2,
const typename K::Point_2 &p1, const typename K::Point_2 &p1,
@ -76,25 +76,6 @@ inline bool do_intersect(const typename K::Triangle_2 &p2,
} }
template <class K>
Point_2_Triangle_2_pair<K>::
Point_2_Triangle_2_pair()
{
_known = false;
_pt = 0;
_trian = 0;
}
template <class K>
Point_2_Triangle_2_pair<K>::
Point_2_Triangle_2_pair(typename K::Point_2 const *pt,
typename K::Triangle_2 const *trian)
{
_known = false;
_pt = pt;
_trian = trian;
}
template <class K> template <class K>
typename Point_2_Triangle_2_pair<K>::Intersection_results typename Point_2_Triangle_2_pair<K>::Intersection_results
Point_2_Triangle_2_pair<K>::intersection_type() const Point_2_Triangle_2_pair<K>::intersection_type() const
@ -134,16 +115,14 @@ Point_2_Triangle_2_pair<K>::intersection_type() const
template <class K> template <class K>
bool typename K::Point_2
Point_2_Triangle_2_pair<K>:: Point_2_Triangle_2_pair<K>::
intersection(typename K::Point_2 &result) const intersection_point() const
{ {
if (!_known) if (!_known)
intersection_type(); intersection_type();
if (_result != POINT) CGAL_kernel_assertion(_result == POINT);
return false; return *_pt;
result = *_pt;
return true;
} }
@ -160,10 +139,9 @@ intersection(const typename K::Point_2 &pt,
case is_t::NO_INTERSECTION: case is_t::NO_INTERSECTION:
default: default:
return Object(); return Object();
case is_t::POINT: { case is_t::POINT:
return make_object(pt); return make_object(pt);
} }
}
} }
template <class K> template <class K>
@ -176,17 +154,6 @@ intersection(const typename K::Triangle_2 &tr,
return CGALi::intersection(pt, tr, k); return CGALi::intersection(pt, tr, k);
} }
template <class K>
class Triangle_2_Point_2_pair
: public Point_2_Triangle_2_pair<K> {
public:
Triangle_2_Point_2_pair(
typename K::Triangle_2 const *trian,
typename K::Point_2 const *pt) :
Point_2_Triangle_2_pair<K>(pt, trian) {}
};
} // namespace CGALi } // namespace CGALi
@ -223,6 +190,7 @@ intersection(const Point_2<K> &pt, const Triangle_2<K> &tr)
typedef typename K::Intersect_2 Intersect; typedef typename K::Intersect_2 Intersect;
return Intersect()(pt, tr); return Intersect()(pt, tr);
} }
CGAL_END_NAMESPACE CGAL_END_NAMESPACE
#endif #endif

View File

@ -41,15 +41,14 @@ template <class K>
class Ray_2_Line_2_pair { class Ray_2_Line_2_pair {
public: public:
enum Intersection_results {NO_INTERSECTION, POINT, RAY}; enum Intersection_results {NO_INTERSECTION, POINT, RAY};
Ray_2_Line_2_pair() ;
Ray_2_Line_2_pair(typename K::Ray_2 const *ray, Ray_2_Line_2_pair(typename K::Ray_2 const *ray,
typename K::Line_2 const *line); typename K::Line_2 const *line)
~Ray_2_Line_2_pair() {} : _ray(ray), _line(line), _known(false) {}
Intersection_results intersection_type() const; Intersection_results intersection_type() const;
bool intersection(typename K::Point_2 &result) const; typename K::Point_2 intersection_point() const;
bool intersection(typename K::Ray_2 &result) const; typename K::Ray_2 intersection_ray() const;
protected: protected:
typename K::Ray_2 const * _ray; typename K::Ray_2 const * _ray;
typename K::Line_2 const * _line; typename K::Line_2 const * _line;
@ -82,15 +81,11 @@ intersection(const typename K::Ray_2 &ray,
case is_t::NO_INTERSECTION: case is_t::NO_INTERSECTION:
default: default:
return Object(); return Object();
case is_t::POINT: { case is_t::POINT:
typename K::Point_2 pt; return make_object(ispair.intersection_point());
ispair.intersection(pt); case is_t::RAY:
return make_object(pt);
}
case is_t::RAY: {
return make_object(ray); return make_object(ray);
} }
}
} }
@ -105,44 +100,19 @@ intersection(const typename K::Line_2 &line,
} }
template <class K>
class Line_2_Ray_2_pair: public Ray_2_Line_2_pair<K> {
public:
Line_2_Ray_2_pair(typename K::Line_2 const *line,
typename K::Ray_2 const *ray) :
Ray_2_Line_2_pair<K>(ray, line) {}
};
template <class K> template <class K>
inline bool do_intersect( inline bool do_intersect(
const typename K::Line_2 &p1, const typename K::Line_2 &p1,
const typename K::Ray_2 &p2, const typename K::Ray_2 &p2,
const K&) const K&)
{ {
typedef Line_2_Ray_2_pair<K> pair_t; typedef Ray_2_Line_2_pair<K> pair_t;
pair_t pair(&p1, &p2); pair_t pair(&p2, &p1);
return pair.intersection_type() != pair_t::NO_INTERSECTION; return pair.intersection_type() != pair_t::NO_INTERSECTION;
} }
template <class K>
Ray_2_Line_2_pair<K>::Ray_2_Line_2_pair()
{
_ray = 0;
_line = 0;
_known = false;
}
template <class K>
Ray_2_Line_2_pair<K>::Ray_2_Line_2_pair(
typename K::Ray_2 const *ray, typename K::Line_2 const *line)
{
_ray = ray;
_line = line;
_known = false;
}
template <class K> template <class K>
typename Ray_2_Line_2_pair<K>::Intersection_results typename Ray_2_Line_2_pair<K>::Intersection_results
Ray_2_Line_2_pair<K>::intersection_type() const Ray_2_Line_2_pair<K>::intersection_type() const
@ -171,28 +141,25 @@ Ray_2_Line_2_pair<K>::intersection_type() const
template <class K> template <class K>
bool typename K::Point_2
Ray_2_Line_2_pair<K>::intersection(typename K::Point_2 &result) const Ray_2_Line_2_pair<K>::intersection_point() const
{ {
if (!_known) if (!_known)
intersection_type(); intersection_type();
if (_result != POINT) CGAL_kernel_assertion(_result == POINT);
return false; return _intersection_point;
result = _intersection_point;
return true;
} }
template <class K> template <class K>
bool typename K::Ray_2
Ray_2_Line_2_pair<K>::intersection(typename K::Ray_2 &result) const Ray_2_Line_2_pair<K>::intersection_ray() const
{ {
if (!_known) if (!_known)
intersection_type(); intersection_type();
if (_result != RAY) CGAL_kernel_assertion(_result == RAY);
return false; return *_ray;
result = *_ray;
return true;
} }
} // namespace CGALi } // namespace CGALi
template <class K> template <class K>
@ -224,8 +191,7 @@ intersection(const Ray_2<K> &ray, const Line_2<K> &line)
typedef typename K::Intersect_2 Intersect; typedef typename K::Intersect_2 Intersect;
return Intersect()(ray, line); return Intersect()(ray, line);
} }
CGAL_END_NAMESPACE CGAL_END_NAMESPACE
#endif #endif

View File

@ -43,16 +43,15 @@ template <class K>
class Ray_2_Ray_2_pair { class Ray_2_Ray_2_pair {
public: public:
enum Intersection_results {NO_INTERSECTION, POINT, SEGMENT, RAY}; enum Intersection_results {NO_INTERSECTION, POINT, SEGMENT, RAY};
Ray_2_Ray_2_pair() ;
Ray_2_Ray_2_pair(typename K::Ray_2 const *ray1, Ray_2_Ray_2_pair(typename K::Ray_2 const *ray1,
typename K::Ray_2 const *ray2); typename K::Ray_2 const *ray2)
~Ray_2_Ray_2_pair() {} : _ray1(ray1), _ray2(ray2), _known(false) {}
Intersection_results intersection_type() const; Intersection_results intersection_type() const;
bool intersection(typename K::Point_2 &result) const; typename K::Point_2 intersection_point() const;
bool intersection(typename K::Segment_2 &result) const; typename K::Segment_2 intersection_segment() const;
bool intersection(typename K::Ray_2 &result) const; typename K::Ray_2 intersection_ray() const;
protected: protected:
typename K::Ray_2 const* _ray1; typename K::Ray_2 const* _ray1;
typename K::Ray_2 const * _ray2; typename K::Ray_2 const * _ray2;
@ -74,23 +73,6 @@ inline bool do_intersect(
template <class K>
Ray_2_Ray_2_pair<K>::Ray_2_Ray_2_pair()
{
_ray1 = 0;
_ray2 = 0;
_known = false;
}
template <class K>
Ray_2_Ray_2_pair<K>::Ray_2_Ray_2_pair(
typename K::Ray_2 const *ray1, typename K::Ray_2 const *ray2)
{
_ray1 = ray1;
_ray2 = ray2;
_known = false;
}
template <class K> template <class K>
typename Ray_2_Ray_2_pair<K>::Intersection_results typename Ray_2_Ray_2_pair<K>::Intersection_results
Ray_2_Ray_2_pair<K>::intersection_type() const Ray_2_Ray_2_pair<K>::intersection_type() const
@ -217,41 +199,35 @@ Ray_2_Ray_2_pair<K>::intersection_type() const
template <class K> template <class K>
bool typename K::Point_2
Ray_2_Ray_2_pair<K>::intersection(typename K::Point_2 &result) const Ray_2_Ray_2_pair<K>::intersection_point() const
{ {
if (!_known) if (!_known)
intersection_type(); intersection_type();
if (_result != POINT) CGAL_kernel_assertion(_result == POINT);
return false; return _intersection_point;
result = _intersection_point;
return true;
} }
template <class K> template <class K>
bool typename K::Segment_2
Ray_2_Ray_2_pair<K>::intersection(typename K::Segment_2 &result) const Ray_2_Ray_2_pair<K>::intersection_segment() const
{ {
typedef typename K::Segment_2 Segment_2; typedef typename K::Segment_2 Segment_2;
if (!_known) if (!_known)
intersection_type(); intersection_type();
if (_result != SEGMENT) CGAL_kernel_assertion(_result == SEGMENT);
return false; return Segment_2(_ray1->source(), _ray2->source());
result = Segment_2(_ray1->source(), _ray2->source());
return true;
} }
template <class K> template <class K>
bool typename K::Ray_2
Ray_2_Ray_2_pair<K>::intersection(typename K::Ray_2 &result) const Ray_2_Ray_2_pair<K>::intersection_ray() const
{ {
typedef typename K::Ray_2 Ray_2; typedef typename K::Ray_2 Ray_2;
if (!_known) if (!_known)
intersection_type(); intersection_type();
if (_result != RAY) CGAL_kernel_assertion(_result == RAY);
return false; return Ray_2(_intersection_point, _ray1->direction());
result = Ray_2(_intersection_point, _ray1->direction());
return true;
} }
@ -268,21 +244,12 @@ intersection(const typename K::Ray_2 &ray1,
case is_t::NO_INTERSECTION: case is_t::NO_INTERSECTION:
default: default:
return Object(); return Object();
case is_t::POINT: { case is_t::POINT:
typename K::Point_2 pt; return make_object(ispair.intersection_point());
ispair.intersection(pt); case is_t::SEGMENT:
return make_object(pt); return make_object(ispair.intersection_segment());
} case is_t::RAY:
case is_t::SEGMENT: { return make_object(ispair.intersection_ray());
typename K::Segment_2 iseg;
ispair.intersection(iseg);
return make_object(iseg);
}
case is_t::RAY: {
typename K::Ray_2 iray;
ispair.intersection(iray);
return make_object(iray);
}
} }
} }

View File

@ -42,15 +42,14 @@ template <class K>
class Ray_2_Segment_2_pair { class Ray_2_Segment_2_pair {
public: public:
enum Intersection_results {NO_INTERSECTION, POINT, SEGMENT}; enum Intersection_results {NO_INTERSECTION, POINT, SEGMENT};
Ray_2_Segment_2_pair() ;
Ray_2_Segment_2_pair(typename K::Ray_2 const *ray, Ray_2_Segment_2_pair(typename K::Ray_2 const *ray,
typename K::Segment_2 const *line); typename K::Segment_2 const *seg)
~Ray_2_Segment_2_pair() {} : _ray(ray), _seg(seg), _known(false) {}
Intersection_results intersection_type() const; Intersection_results intersection_type() const;
bool intersection(typename K::Point_2 &result) const; typename K::Point_2 intersection_point() const;
bool intersection(typename K::Segment_2 &result) const; typename K::Segment_2 intersection_segment() const;
protected: protected:
typename K::Ray_2 const * _ray; typename K::Ray_2 const * _ray;
typename K::Segment_2 const * _seg; typename K::Segment_2 const * _seg;
@ -77,23 +76,6 @@ inline bool do_intersect(const typename K::Segment_2 &p2,
return CGALi::do_intersect(p1, p2, k); return CGALi::do_intersect(p1, p2, k);
} }
template <class K>
Ray_2_Segment_2_pair<K>::Ray_2_Segment_2_pair()
{
_ray = 0;
_seg = 0;
_known = false;
}
template <class K>
Ray_2_Segment_2_pair<K>::Ray_2_Segment_2_pair(
typename K::Ray_2 const *ray, typename K::Segment_2 const *seg)
{
_ray = ray;
_seg = seg;
_known = false;
}
template <class K> template <class K>
typename Ray_2_Segment_2_pair<K>::Intersection_results typename Ray_2_Segment_2_pair<K>::Intersection_results
Ray_2_Segment_2_pair<K>::intersection_type() const Ray_2_Segment_2_pair<K>::intersection_type() const
@ -230,28 +212,24 @@ Ray_2_Segment_2_pair<K>::intersection_type() const
} }
template <class K> template <class K>
bool typename K::Point_2
Ray_2_Segment_2_pair<K>::intersection(typename K::Point_2 &result) const Ray_2_Segment_2_pair<K>::intersection_point() const
{ {
if (!_known) if (!_known)
intersection_type(); intersection_type();
if (_result != POINT) CGAL_kernel_assertion(_result == POINT);
return false; return _intersection_point;
result = _intersection_point;
return true;
} }
template <class K> template <class K>
bool typename K::Segment_2
Ray_2_Segment_2_pair<K>::intersection(typename K::Segment_2 &result) const Ray_2_Segment_2_pair<K>::intersection_segment() const
{ {
typedef typename K::Segment_2 Segment_2; typedef typename K::Segment_2 Segment_2;
if (!_known) if (!_known)
intersection_type(); intersection_type();
if (_result != SEGMENT) CGAL_kernel_assertion(_result == SEGMENT);
return false; return Segment_2(_intersection_point, _other_point);
result = Segment_2(_intersection_point, _other_point);
return true;
} }
@ -268,16 +246,10 @@ intersection(const typename K::Ray_2 &ray,
case is_t::NO_INTERSECTION: case is_t::NO_INTERSECTION:
default: default:
return Object(); return Object();
case is_t::POINT: { case is_t::POINT:
typename K::Point_2 pt; return make_object(ispair.intersection_point());
ispair.intersection(pt); case is_t::SEGMENT:
return make_object(pt); return make_object(ispair.intersection_segment());
}
case is_t::SEGMENT: {
typename K::Segment_2 iseg;
ispair.intersection(iseg);
return make_object(iseg);
}
} }
} }
@ -291,17 +263,6 @@ intersection(const typename K::Segment_2 &seg,
return CGALi::intersection(ray, seg, k); return CGALi::intersection(ray, seg, k);
} }
template <class K>
class Segment_2_Ray_2_pair: public Ray_2_Segment_2_pair<K> {
public:
Segment_2_Ray_2_pair(
typename K::Segment_2 const *seg,
typename K::Ray_2 const *ray) :
Ray_2_Segment_2_pair<K>(ray, seg) {}
};
} // namespace CGALi } // namespace CGALi
template <class K> template <class K>
@ -337,6 +298,7 @@ intersection(const Ray_2<K> &ray, const Segment_2<K> &seg)
typedef typename K::Intersect_2 Intersect; typedef typename K::Intersect_2 Intersect;
return Intersect()(ray, seg); return Intersect()(ray, seg);
} }
CGAL_END_NAMESPACE CGAL_END_NAMESPACE
#endif #endif

View File

@ -46,15 +46,14 @@ template <class K>
class Ray_2_Triangle_2_pair { class Ray_2_Triangle_2_pair {
public: public:
enum Intersection_results {NO_INTERSECTION, POINT, SEGMENT}; enum Intersection_results {NO_INTERSECTION, POINT, SEGMENT};
Ray_2_Triangle_2_pair() ;
Ray_2_Triangle_2_pair(typename K::Ray_2 const *ray, Ray_2_Triangle_2_pair(typename K::Ray_2 const *ray,
typename K::Triangle_2 const *trian); typename K::Triangle_2 const *trian)
~Ray_2_Triangle_2_pair() {} : _ray(ray), _trian(trian), _known(false) {}
Intersection_results intersection_type() const; Intersection_results intersection_type() const;
bool intersection(typename K::Point_2 &result) const; typename K::Point_2 intersection_point() const;
bool intersection(typename K::Segment_2 &result) const; typename K::Segment_2 intersection_segment() const;
protected: protected:
typename K::Ray_2 const* _ray; typename K::Ray_2 const* _ray;
typename K::Triangle_2 const * _trian; typename K::Triangle_2 const * _trian;
@ -66,29 +65,6 @@ protected:
template <class K>
Ray_2_Triangle_2_pair<K>::
Ray_2_Triangle_2_pair()
{
_known = false;
_ray = 0;
_trian = 0;
}
template <class K>
Ray_2_Triangle_2_pair<K>::
Ray_2_Triangle_2_pair(typename K::Ray_2 const *ray,
typename K::Triangle_2 const *trian)
{
_known = false;
_ray = ray;
_trian = trian;
}
template <class K> template <class K>
typename Ray_2_Triangle_2_pair<K>::Intersection_results typename Ray_2_Triangle_2_pair<K>::Intersection_results
Ray_2_Triangle_2_pair<K>::intersection_type() const Ray_2_Triangle_2_pair<K>::intersection_type() const
@ -142,30 +118,26 @@ if (l.oriented_side(_trian->vertex(2)) == ON_POSITIVE_SIDE) {
template <class K> template <class K>
bool typename K::Point_2
Ray_2_Triangle_2_pair<K>:: Ray_2_Triangle_2_pair<K>::
intersection(typename K::Point_2 &result) const intersection_point() const
{ {
if (!_known) if (!_known)
intersection_type(); intersection_type();
if (_result != POINT) CGAL_kernel_assertion(_result == POINT);
return false; return _intersection_point;
result = _intersection_point;
return true;
} }
template <class K> template <class K>
bool typename K::Segment_2
Ray_2_Triangle_2_pair<K>:: Ray_2_Triangle_2_pair<K>::
intersection(typename K::Segment_2 &result) const intersection_segment() const
{ {
typedef typename K::Segment_2 Segment_2; typedef typename K::Segment_2 Segment_2;
if (!_known) if (!_known)
intersection_type(); intersection_type();
if (_result != SEGMENT) CGAL_kernel_assertion(_result == SEGMENT);
return false; return Segment_2(_intersection_point, _other_point);
result = Segment_2(_intersection_point, _other_point);
return true;
} }
@ -184,16 +156,10 @@ intersection(const typename K::Ray_2 &ray,
case is_t::NO_INTERSECTION: case is_t::NO_INTERSECTION:
default: default:
return Object(); return Object();
case is_t::POINT: { case is_t::POINT:
typename K::Point_2 pt; return make_object(ispair.intersection_segment());
ispair.intersection(pt); case is_t::SEGMENT:
return make_object(pt); return make_object(ispair.intersection_segment());
}
case is_t::SEGMENT: {
typename K::Segment_2 iseg;
ispair.intersection(iseg);
return make_object(iseg);
}
} }
} }
@ -207,15 +173,6 @@ intersection(const typename K::Triangle_2&tr,
} }
template <class K>
class Triangle_2_Ray_2_pair
: public Ray_2_Triangle_2_pair<K> {
public:
Triangle_2_Ray_2_pair(
typename K::Triangle_2 const *trian,
typename K::Ray_2 const *ray) :
Ray_2_Triangle_2_pair<K>(ray, trian) {}
};
template <class K> template <class K>
inline bool do_intersect( inline bool do_intersect(
@ -235,8 +192,8 @@ inline bool do_intersect(
const typename K::Ray_2 &p2, const typename K::Ray_2 &p2,
const K&) const K&)
{ {
typedef Triangle_2_Ray_2_pair<K> pair_t; typedef Ray_2_Triangle_2_pair<K> pair_t;
pair_t pair(&p1, &p2); pair_t pair(&p2, &p1);
return pair.intersection_type() != pair_t::NO_INTERSECTION; return pair.intersection_type() != pair_t::NO_INTERSECTION;
} }
@ -266,6 +223,7 @@ intersection(const Ray_2<K> &ray, const Triangle_2<K> &tr)
typedef typename K::Intersect_2 Intersect; typedef typename K::Intersect_2 Intersect;
return Intersect()(ray, tr); return Intersect()(ray, tr);
} }
template <class K> template <class K>
inline Object inline Object
intersection(const Triangle_2<K> &tr, const Ray_2<K> &ray) intersection(const Triangle_2<K> &tr, const Ray_2<K> &ray)
@ -273,6 +231,7 @@ intersection(const Triangle_2<K> &tr, const Ray_2<K> &ray)
typedef typename K::Intersect_2 Intersect; typedef typename K::Intersect_2 Intersect;
return Intersect()(ray, tr); return Intersect()(ray, tr);
} }
CGAL_END_NAMESPACE CGAL_END_NAMESPACE
#endif #endif

View File

@ -42,15 +42,14 @@ template <class K>
class Segment_2_Triangle_2_pair { class Segment_2_Triangle_2_pair {
public: public:
enum Intersection_results {NO_INTERSECTION, POINT, SEGMENT}; enum Intersection_results {NO_INTERSECTION, POINT, SEGMENT};
Segment_2_Triangle_2_pair() ;
Segment_2_Triangle_2_pair(typename K::Segment_2 const *seg, Segment_2_Triangle_2_pair(typename K::Segment_2 const *seg,
typename K::Triangle_2 const *trian); typename K::Triangle_2 const *trian)
~Segment_2_Triangle_2_pair() {} : _seg(seg), _trian(trian), _known(false) {}
Intersection_results intersection_type() const; Intersection_results intersection_type() const;
bool intersection(typename K::Point_2 &result) const; typename K::Point_2 intersection_point() const;
bool intersection(typename K::Segment_2 &result) const; typename K::Segment_2 intersection_segment() const;
protected: protected:
typename K::Segment_2 const * _seg; typename K::Segment_2 const * _seg;
typename K::Triangle_2 const * _trian; typename K::Triangle_2 const * _trian;
@ -75,25 +74,6 @@ inline bool do_intersect(
template <class K>
Segment_2_Triangle_2_pair<K>::
Segment_2_Triangle_2_pair()
{
_known = false;
_seg = 0;
_trian = 0;
}
template <class K>
Segment_2_Triangle_2_pair<K>::
Segment_2_Triangle_2_pair(typename K::Segment_2 const *seg,
typename K::Triangle_2 const *trian)
{
_known = false;
_seg = seg;
_trian = trian;
}
template <class K> template <class K>
typename Segment_2_Triangle_2_pair<K>::Intersection_results typename Segment_2_Triangle_2_pair<K>::Intersection_results
Segment_2_Triangle_2_pair<K>::intersection_type() const Segment_2_Triangle_2_pair<K>::intersection_type() const
@ -147,30 +127,26 @@ if (l.oriented_side(_trian->vertex(2)) == ON_POSITIVE_SIDE) {
template <class K> template <class K>
bool typename K::Point_2
Segment_2_Triangle_2_pair<K>:: Segment_2_Triangle_2_pair<K>::
intersection(typename K::Point_2 &result) const intersection_point() const
{ {
if (!_known) if (!_known)
intersection_type(); intersection_type();
if (_result != POINT) CGAL_kernel_assertion(_result == POINT);
return false; return _intersection_point;
result = _intersection_point;
return true;
} }
template <class K> template <class K>
bool typename K::Segment_2
Segment_2_Triangle_2_pair<K>:: Segment_2_Triangle_2_pair<K>::
intersection(typename K::Segment_2 &result) const intersection_segment() const
{ {
typedef typename K::Segment_2 Segment_2; typedef typename K::Segment_2 Segment_2;
if (!_known) if (!_known)
intersection_type(); intersection_type();
if (_result != SEGMENT) CGAL_kernel_assertion(_result == SEGMENT);
return false; return Segment_2(_intersection_point, _other_point);
result = Segment_2(_intersection_point, _other_point);
return true;
} }
@ -188,16 +164,10 @@ intersection(const typename K::Segment_2 &seg,
case is_t::NO_INTERSECTION: case is_t::NO_INTERSECTION:
default: default:
return Object(); return Object();
case is_t::POINT: { case is_t::POINT:
typename K::Point_2 pt; return make_object(ispair.intersection_point());
ispair.intersection(pt); case is_t::SEGMENT:
return make_object(pt); return make_object(ispair.intersection_segment());
}
case is_t::SEGMENT: {
typename K::Segment_2 iseg;
ispair.intersection(iseg);
return make_object(iseg);
}
} }
} }
@ -212,24 +182,14 @@ intersection(const typename K::Triangle_2&tr,
} }
template <class K>
class Triangle_2_Segment_2_pair
: public Segment_2_Triangle_2_pair<K> {
public:
Triangle_2_Segment_2_pair(
typename K::Triangle_2 const *trian,
typename K::Segment_2 const *seg) :
Segment_2_Triangle_2_pair<K>(seg, trian) {}
};
template <class K> template <class K>
inline bool do_intersect( inline bool do_intersect(
const typename K::Triangle_2 &p1, const typename K::Triangle_2 &p1,
const typename K::Segment_2 &p2, const typename K::Segment_2 &p2,
const K&) const K&)
{ {
typedef Triangle_2_Segment_2_pair<K> pair_t; typedef Segment_2_Triangle_2_pair<K> pair_t;
pair_t pair(&p1, &p2); pair_t pair(&p2, &p1);
return pair.intersection_type() != pair_t::NO_INTERSECTION; return pair.intersection_type() != pair_t::NO_INTERSECTION;
} }

View File

@ -56,7 +56,6 @@ public:
Straight_2_(typename K::Ray_2 const &ray) ; Straight_2_(typename K::Ray_2 const &ray) ;
Straight_2_(typename K::Ray_2 const &ray,bool cooriented) ; Straight_2_(typename K::Ray_2 const &ray,bool cooriented) ;
Straight_2_(typename K::Segment_2 const &seg) ; Straight_2_(typename K::Segment_2 const &seg) ;
~Straight_2_() {}
void cut_right_off(typename K::Line_2 const & cutter) ; void cut_right_off(typename K::Line_2 const & cutter) ;
int collinear_order(typename K::Point_2 const & p1, int collinear_order(typename K::Point_2 const & p1,
typename K::Point_2 const &p2) const ; typename K::Point_2 const &p2) const ;