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_() ;
};
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>
@ -191,24 +155,30 @@ void _cut_off(Pointlist_2_<K> &list,
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>
Triangle_2_Triangle_2_pair<K>::
class Triangle_2_Triangle_2_pair {
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)
{
_trian1 = trian1;
_trian2 = trian2;
_known = false;
}
: _trian1(trian1), _trian2(trian2), _known(false) {}
Intersection_results intersection_type() const;
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>
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>
bool
Triangle_2_Triangle_2_pair<K>::intersection(
typename K::Triangle_2 &result) const
typename K::Triangle_2
Triangle_2_Triangle_2_pair<K>::intersection_triangle() const
{
typedef typename K::Triangle_2 Triangle_2;
if (!_known)
intersection_type();
if (_result != TRIANGLE)
return false;
result = Triangle_2(_pointlist.first->point,
CGAL_kernel_assertion(_result == TRIANGLE);
return Triangle_2(_pointlist.first->point,
_pointlist.first->next->point,
_pointlist.first->next->next->point);
return true;
}
template <class K>
bool
Triangle_2_Triangle_2_pair<K>::intersection(
typename K::Segment_2 &seg) const
typename K::Segment_2
Triangle_2_Triangle_2_pair<K>::intersection_segment() const
{
typedef typename K::Segment_2 Segment_2;
if (!_known)
intersection_type();
if (_result != SEGMENT)
return false;
seg = Segment_2(_pointlist.first->point,
CGAL_kernel_assertion(_result == SEGMENT);
return Segment_2(_pointlist.first->point,
_pointlist.first->next->point);
return true;
}
template <class K>
bool
Triangle_2_Triangle_2_pair<K>::intersection(
typename K::Point_2 &pt) const
typename K::Point_2
Triangle_2_Triangle_2_pair<K>::intersection_point() const
{
if (!_known)
intersection_type();
if (_result != POINT)
return false;
pt = _pointlist.first->point;
return true;
CGAL_kernel_assertion(_result == POINT);
return _pointlist.first->point;
}
@ -367,21 +328,12 @@ intersection(const typename K::Triangle_2 &tr1,
case is_t::NO_INTERSECTION:
default:
return Object();
case is_t::POINT: {
typename K::Point_2 pt;
ispair.intersection(pt);
return make_object(pt);
}
case is_t::SEGMENT: {
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::POINT:
return make_object(ispair.intersection_point());
case is_t::SEGMENT:
return make_object(ispair.intersection_segment());
case is_t::TRIANGLE:
return make_object(ispair.intersection_triangle());
case is_t::POLYGON: {
typedef std::vector<typename K::Point_2> Container;
Container points(ispair.vertex_count());

View File

@ -40,15 +40,18 @@ template <class K>
class Line_2_Iso_rectangle_2_pair {
public:
enum Intersection_results {NO_INTERSECTION, POINT, SEGMENT};
Line_2_Iso_rectangle_2_pair() ;
Line_2_Iso_rectangle_2_pair(typename K::Line_2 const *pt,
typename K::Iso_rectangle_2 const *iso);
~Line_2_Iso_rectangle_2_pair() {}
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)()) {}
Intersection_results intersection_type() const;
bool intersection(typename K::Point_2 &result) const;
bool intersection(typename K::Segment_2 &result) const;
typename K::Point_2 intersection_point() const;
typename K::Segment_2 intersection_segment() const;
protected:
mutable bool _known;
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>
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>
bool
typename K::Point_2
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_scaled_vector_2 construct_scaled_vector;
if (!_known)
intersection_type();
if (_result != POINT)
return false;
result = translated_point(_ref_point, construct_scaled_vector(_dir, _min));
return true;
CGAL_kernel_assertion(_result == POINT);
return translated_point(_ref_point, construct_scaled_vector(_dir, _min));
}
template <class K>
bool
typename K::Segment_2
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_translated_point_2 translated_point;
typename K::Construct_scaled_vector_2 construct_scaled_vector;
if (!_known)
intersection_type();
if (_result != SEGMENT)
return false;
result = construct_segment_2(translated_point(_ref_point, construct_scaled_vector(_dir,_min)),
CGAL_kernel_assertion(_result == SEGMENT);
return construct_segment_2(translated_point(_ref_point, construct_scaled_vector(_dir,_min)),
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:
default:
return Object();
case is_t::POINT: {
typename K::Point_2 ipt;
ispair.intersection(ipt);
return construct_object(ipt);
}
case is_t::SEGMENT: {
typename K::Segment_2 iseg;
ispair.intersection(iseg);
return construct_object(iseg);
}
case is_t::POINT:
return construct_object(ispair.intersection_point());
case is_t::SEGMENT:
return construct_object(ispair.intersection_segment());
}
}
@ -237,21 +212,9 @@ intersection(const typename K::Iso_rectangle_2 &iso,
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
template <class K>
inline bool do_intersect(
const Line_2<K> &p1,

View File

@ -42,15 +42,14 @@ template <class K>
class Line_2_Triangle_2_pair {
public:
enum Intersection_results {NO_INTERSECTION, POINT, SEGMENT};
Line_2_Triangle_2_pair() ;
Line_2_Triangle_2_pair(typename K::Line_2 const *line,
typename K::Triangle_2 const *trian);
~Line_2_Triangle_2_pair() {}
typename K::Triangle_2 const *trian)
: _line(line), _trian(trian), _known(false) {}
Intersection_results intersection_type() const;
bool intersection(typename K::Point_2 &result) const;
bool intersection(typename K::Segment_2 &result) const;
typename K::Point_2 intersection_point() const;
typename K::Segment_2 intersection_segment() const;
protected:
typename K::Line_2 const*_line;
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);
}
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>
typename Line_2_Triangle_2_pair<K>::Intersection_results
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>
bool
typename K::Point_2
Line_2_Triangle_2_pair<K>::
intersection(typename K::Point_2 &result) const
intersection_point() const
{
if (!_known)
intersection_type();
if (_result != POINT)
return false;
result = _intersection_point;
return true;
CGAL_kernel_assertion(_result == POINT);
return _intersection_point;
}
template <class K>
bool
typename K::Segment_2
Line_2_Triangle_2_pair<K>::
intersection(typename K::Segment_2 &result) const
intersection_segment() const
{
typedef typename K::Segment_2 Segment_2;
if (!_known)
intersection_type();
if (_result != SEGMENT)
return false;
result = Segment_2(_intersection_point, _other_point);
return true;
CGAL_kernel_assertion(_result == SEGMENT);
return Segment_2(_intersection_point, _other_point);
}
@ -195,16 +171,10 @@ intersection(const typename K::Line_2 &line,
case is_t::NO_INTERSECTION:
default:
return Object();
case is_t::POINT: {
typename K::Point_2 pt;
ispair.intersection(pt);
return make_object(pt);
}
case is_t::SEGMENT: {
typename K::Segment_2 iseg;
ispair.intersection(iseg);
return make_object(iseg);
}
case is_t::POINT:
return make_object(ispair.intersection_point());
case is_t::SEGMENT:
return make_object(ispair.intersection_segment());
}
}
@ -219,17 +189,6 @@ intersection(const typename K::Triangle_2 &tr,
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
template <class K>

View File

@ -41,14 +41,13 @@ template <class K>
class Point_2_Triangle_2_pair {
public:
enum Intersection_results {NO_INTERSECTION, POINT};
Point_2_Triangle_2_pair() ;
Point_2_Triangle_2_pair(typename K::Point_2 const *pt,
typename K::Triangle_2 const *trian);
~Point_2_Triangle_2_pair() {}
typename K::Triangle_2 const *trian)
: _pt(pt), _trian(trian), _known(false) {}
Intersection_results intersection_type() const;
bool intersection(typename K::Point_2 &result) const;
typename K::Point_2 intersection_point() const;
protected:
typename K::Point_2 const * _pt;
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);
return pair.intersection_type() != pair_t::NO_INTERSECTION;
}
template <class K>
inline bool do_intersect(const typename K::Triangle_2 &p2,
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>
typename Point_2_Triangle_2_pair<K>::Intersection_results
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>
bool
typename K::Point_2
Point_2_Triangle_2_pair<K>::
intersection(typename K::Point_2 &result) const
intersection_point() const
{
if (!_known)
intersection_type();
if (_result != POINT)
return false;
result = *_pt;
return true;
CGAL_kernel_assertion(_result == POINT);
return *_pt;
}
@ -160,11 +139,10 @@ intersection(const typename K::Point_2 &pt,
case is_t::NO_INTERSECTION:
default:
return Object();
case is_t::POINT: {
case is_t::POINT:
return make_object(pt);
}
}
}
template <class K>
inline
@ -176,17 +154,6 @@ intersection(const typename K::Triangle_2 &tr,
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
@ -223,6 +190,7 @@ intersection(const Point_2<K> &pt, const Triangle_2<K> &tr)
typedef typename K::Intersect_2 Intersect;
return Intersect()(pt, tr);
}
CGAL_END_NAMESPACE
#endif

View File

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

View File

@ -43,16 +43,15 @@ template <class K>
class Ray_2_Ray_2_pair {
public:
enum Intersection_results {NO_INTERSECTION, POINT, SEGMENT, RAY};
Ray_2_Ray_2_pair() ;
Ray_2_Ray_2_pair(typename K::Ray_2 const *ray1,
typename K::Ray_2 const *ray2);
~Ray_2_Ray_2_pair() {}
typename K::Ray_2 const *ray2)
: _ray1(ray1), _ray2(ray2), _known(false) {}
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::Ray_2 &result) const;
typename K::Point_2 intersection_point() const;
typename K::Segment_2 intersection_segment() const;
typename K::Ray_2 intersection_ray() const;
protected:
typename K::Ray_2 const* _ray1;
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>
typename Ray_2_Ray_2_pair<K>::Intersection_results
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>
bool
Ray_2_Ray_2_pair<K>::intersection(typename K::Point_2 &result) const
typename K::Point_2
Ray_2_Ray_2_pair<K>::intersection_point() const
{
if (!_known)
intersection_type();
if (_result != POINT)
return false;
result = _intersection_point;
return true;
CGAL_kernel_assertion(_result == POINT);
return _intersection_point;
}
template <class K>
bool
Ray_2_Ray_2_pair<K>::intersection(typename K::Segment_2 &result) const
typename K::Segment_2
Ray_2_Ray_2_pair<K>::intersection_segment() const
{
typedef typename K::Segment_2 Segment_2;
if (!_known)
intersection_type();
if (_result != SEGMENT)
return false;
result = Segment_2(_ray1->source(), _ray2->source());
return true;
CGAL_kernel_assertion(_result == SEGMENT);
return Segment_2(_ray1->source(), _ray2->source());
}
template <class K>
bool
Ray_2_Ray_2_pair<K>::intersection(typename K::Ray_2 &result) const
typename K::Ray_2
Ray_2_Ray_2_pair<K>::intersection_ray() const
{
typedef typename K::Ray_2 Ray_2;
if (!_known)
intersection_type();
if (_result != RAY)
return false;
result = Ray_2(_intersection_point, _ray1->direction());
return true;
CGAL_kernel_assertion(_result == RAY);
return Ray_2(_intersection_point, _ray1->direction());
}
@ -268,21 +244,12 @@ intersection(const typename K::Ray_2 &ray1,
case is_t::NO_INTERSECTION:
default:
return Object();
case is_t::POINT: {
typename K::Point_2 pt;
ispair.intersection(pt);
return make_object(pt);
}
case is_t::SEGMENT: {
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);
}
case is_t::POINT:
return make_object(ispair.intersection_point());
case is_t::SEGMENT:
return make_object(ispair.intersection_segment());
case is_t::RAY:
return make_object(ispair.intersection_ray());
}
}

View File

@ -42,15 +42,14 @@ template <class K>
class Ray_2_Segment_2_pair {
public:
enum Intersection_results {NO_INTERSECTION, POINT, SEGMENT};
Ray_2_Segment_2_pair() ;
Ray_2_Segment_2_pair(typename K::Ray_2 const *ray,
typename K::Segment_2 const *line);
~Ray_2_Segment_2_pair() {}
typename K::Segment_2 const *seg)
: _ray(ray), _seg(seg), _known(false) {}
Intersection_results intersection_type() const;
bool intersection(typename K::Point_2 &result) const;
bool intersection(typename K::Segment_2 &result) const;
typename K::Point_2 intersection_point() const;
typename K::Segment_2 intersection_segment() const;
protected:
typename K::Ray_2 const * _ray;
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);
}
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>
typename Ray_2_Segment_2_pair<K>::Intersection_results
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>
bool
Ray_2_Segment_2_pair<K>::intersection(typename K::Point_2 &result) const
typename K::Point_2
Ray_2_Segment_2_pair<K>::intersection_point() const
{
if (!_known)
intersection_type();
if (_result != POINT)
return false;
result = _intersection_point;
return true;
CGAL_kernel_assertion(_result == POINT);
return _intersection_point;
}
template <class K>
bool
Ray_2_Segment_2_pair<K>::intersection(typename K::Segment_2 &result) const
typename K::Segment_2
Ray_2_Segment_2_pair<K>::intersection_segment() const
{
typedef typename K::Segment_2 Segment_2;
if (!_known)
intersection_type();
if (_result != SEGMENT)
return false;
result = Segment_2(_intersection_point, _other_point);
return true;
CGAL_kernel_assertion(_result == SEGMENT);
return Segment_2(_intersection_point, _other_point);
}
@ -268,16 +246,10 @@ intersection(const typename K::Ray_2 &ray,
case is_t::NO_INTERSECTION:
default:
return Object();
case is_t::POINT: {
typename K::Point_2 pt;
ispair.intersection(pt);
return make_object(pt);
}
case is_t::SEGMENT: {
typename K::Segment_2 iseg;
ispair.intersection(iseg);
return make_object(iseg);
}
case is_t::POINT:
return make_object(ispair.intersection_point());
case is_t::SEGMENT:
return make_object(ispair.intersection_segment());
}
}
@ -291,17 +263,6 @@ intersection(const typename K::Segment_2 &seg,
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
template <class K>
@ -337,6 +298,7 @@ intersection(const Ray_2<K> &ray, const Segment_2<K> &seg)
typedef typename K::Intersect_2 Intersect;
return Intersect()(ray, seg);
}
CGAL_END_NAMESPACE
#endif

View File

@ -46,15 +46,14 @@ template <class K>
class Ray_2_Triangle_2_pair {
public:
enum Intersection_results {NO_INTERSECTION, POINT, SEGMENT};
Ray_2_Triangle_2_pair() ;
Ray_2_Triangle_2_pair(typename K::Ray_2 const *ray,
typename K::Triangle_2 const *trian);
~Ray_2_Triangle_2_pair() {}
typename K::Triangle_2 const *trian)
: _ray(ray), _trian(trian), _known(false) {}
Intersection_results intersection_type() const;
bool intersection(typename K::Point_2 &result) const;
bool intersection(typename K::Segment_2 &result) const;
typename K::Point_2 intersection_point() const;
typename K::Segment_2 intersection_segment() const;
protected:
typename K::Ray_2 const* _ray;
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>
typename Ray_2_Triangle_2_pair<K>::Intersection_results
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>
bool
typename K::Point_2
Ray_2_Triangle_2_pair<K>::
intersection(typename K::Point_2 &result) const
intersection_point() const
{
if (!_known)
intersection_type();
if (_result != POINT)
return false;
result = _intersection_point;
return true;
CGAL_kernel_assertion(_result == POINT);
return _intersection_point;
}
template <class K>
bool
typename K::Segment_2
Ray_2_Triangle_2_pair<K>::
intersection(typename K::Segment_2 &result) const
intersection_segment() const
{
typedef typename K::Segment_2 Segment_2;
if (!_known)
intersection_type();
if (_result != SEGMENT)
return false;
result = Segment_2(_intersection_point, _other_point);
return true;
CGAL_kernel_assertion(_result == SEGMENT);
return Segment_2(_intersection_point, _other_point);
}
@ -184,16 +156,10 @@ intersection(const typename K::Ray_2 &ray,
case is_t::NO_INTERSECTION:
default:
return Object();
case is_t::POINT: {
typename K::Point_2 pt;
ispair.intersection(pt);
return make_object(pt);
}
case is_t::SEGMENT: {
typename K::Segment_2 iseg;
ispair.intersection(iseg);
return make_object(iseg);
}
case is_t::POINT:
return make_object(ispair.intersection_segment());
case is_t::SEGMENT:
return make_object(ispair.intersection_segment());
}
}
@ -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>
inline bool do_intersect(
@ -235,8 +192,8 @@ inline bool do_intersect(
const typename K::Ray_2 &p2,
const K&)
{
typedef Triangle_2_Ray_2_pair<K> pair_t;
pair_t pair(&p1, &p2);
typedef Ray_2_Triangle_2_pair<K> pair_t;
pair_t pair(&p2, &p1);
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;
return Intersect()(ray, tr);
}
template <class K>
inline Object
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;
return Intersect()(ray, tr);
}
CGAL_END_NAMESPACE
#endif

View File

@ -42,15 +42,14 @@ template <class K>
class Segment_2_Triangle_2_pair {
public:
enum Intersection_results {NO_INTERSECTION, POINT, SEGMENT};
Segment_2_Triangle_2_pair() ;
Segment_2_Triangle_2_pair(typename K::Segment_2 const *seg,
typename K::Triangle_2 const *trian);
~Segment_2_Triangle_2_pair() {}
typename K::Triangle_2 const *trian)
: _seg(seg), _trian(trian), _known(false) {}
Intersection_results intersection_type() const;
bool intersection(typename K::Point_2 &result) const;
bool intersection(typename K::Segment_2 &result) const;
typename K::Point_2 intersection_point() const;
typename K::Segment_2 intersection_segment() const;
protected:
typename K::Segment_2 const * _seg;
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>
typename Segment_2_Triangle_2_pair<K>::Intersection_results
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>
bool
typename K::Point_2
Segment_2_Triangle_2_pair<K>::
intersection(typename K::Point_2 &result) const
intersection_point() const
{
if (!_known)
intersection_type();
if (_result != POINT)
return false;
result = _intersection_point;
return true;
CGAL_kernel_assertion(_result == POINT);
return _intersection_point;
}
template <class K>
bool
typename K::Segment_2
Segment_2_Triangle_2_pair<K>::
intersection(typename K::Segment_2 &result) const
intersection_segment() const
{
typedef typename K::Segment_2 Segment_2;
if (!_known)
intersection_type();
if (_result != SEGMENT)
return false;
result = Segment_2(_intersection_point, _other_point);
return true;
CGAL_kernel_assertion(_result == SEGMENT);
return Segment_2(_intersection_point, _other_point);
}
@ -188,16 +164,10 @@ intersection(const typename K::Segment_2 &seg,
case is_t::NO_INTERSECTION:
default:
return Object();
case is_t::POINT: {
typename K::Point_2 pt;
ispair.intersection(pt);
return make_object(pt);
}
case is_t::SEGMENT: {
typename K::Segment_2 iseg;
ispair.intersection(iseg);
return make_object(iseg);
}
case is_t::POINT:
return make_object(ispair.intersection_point());
case is_t::SEGMENT:
return make_object(ispair.intersection_segment());
}
}
@ -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>
inline bool do_intersect(
const typename K::Triangle_2 &p1,
const typename K::Segment_2 &p2,
const K&)
{
typedef Triangle_2_Segment_2_pair<K> pair_t;
pair_t pair(&p1, &p2);
typedef Segment_2_Triangle_2_pair<K> pair_t;
pair_t pair(&p2, &p1);
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,bool cooriented) ;
Straight_2_(typename K::Segment_2 const &seg) ;
~Straight_2_() {}
void cut_right_off(typename K::Line_2 const & cutter) ;
int collinear_order(typename K::Point_2 const & p1,
typename K::Point_2 const &p2) const ;