// ====================================================================== // // Copyright (c) 1999 The CGAL Consortium // // This software and related documentation is part of an INTERNAL release // of the Computational Geometry Algorithms Library (CGAL). It is not // intended for general use. // // ---------------------------------------------------------------------- // // release : // release_date : // // file : Segment_2.h // package : _2 // revision : $Revision$ // revision_date : $Date$ // author(s) : Andreas Fabri // // coordinator : MPI, Saarbruecken () // ====================================================================== #ifndef CGAL_SEGMENT_2_H #define CGAL_SEGMENT_2_H #ifndef CGAL_REP_CLASS_DEFINED #error no representation class defined #endif #if defined CGAL_HOMOGENEOUS_H || defined CGAL_SIMPLE_HOMOGENEOUS_H #include #endif #if defined CGAL_CARTESIAN_H || defined CGAL_SIMPLE_CARTESIAN_H #include #endif #include #include #include CGAL_BEGIN_NAMESPACE template class Segment_2 : public R_::Segment_2_base { public: typedef R_ R; typedef typename R::RT RT; typedef typename R::FT FT; typedef typename R::Segment_2_base RSegment_2; Segment_2() // doesn't the default constructor do the same ??? : RSegment_2() // does the handle stuff {} ~Segment_2() {} Segment_2(const CGAL::Segment_2& s) : RSegment_2(static_cast(s)) // does the handle stuff {} Segment_2(const CGAL::Point_2 &sp, const CGAL::Point_2 &ep) : RSegment_2(sp,ep) {} // conversion from implementation class object to interface class object Segment_2(const RSegment_2& s) : RSegment_2(s) // does the handle stuff {} bool is_horizontal() const { return RSegment_2::is_horizontal(); } bool is_vertical() const { return RSegment_2::is_vertical(); } bool has_on(const CGAL::Point_2 &p) const { return RSegment_2::has_on(p); } bool collinear_has_on(const CGAL::Point_2 &p) const { return RSegment_2::collinear_has_on(p); } bool operator==(const CGAL::Segment_2 &s) const { return RSegment_2::operator==(s); } bool operator!=(const CGAL::Segment_2 &s) const { return !(*this == s); } CGAL::Point_2 start() const { return RSegment_2::start(); } CGAL::Point_2 end() const { return RSegment_2::end(); } CGAL::Point_2 source() const { return RSegment_2::source(); } CGAL::Point_2 target() const { return RSegment_2::target(); } CGAL::Point_2 min() const { return RSegment_2::min(); } CGAL::Point_2 max() const { return RSegment_2::max(); } CGAL::Point_2 vertex(int i) const { return RSegment_2::vertex(i); } CGAL::Point_2 point(int i) const { return RSegment_2::vertex(i); } CGAL::Point_2 operator[](int i) const { return vertex(i); } FT squared_length() const { return RSegment_2::squared_length(); } CGAL::Direction_2 direction() const { return RSegment_2::direction(); } CGAL::Segment_2 opposite() const { return CGAL::Segment_2(target(),source()); } // this makes use of the constructor of the interface class // taking an object of the implemetation class as argument. CGAL::Segment_2 transform(const CGAL::Aff_transformation_2 &t) const { return RSegment_2::transform(t); } CGAL::Line_2 supporting_line() const { return RSegment_2::supporting_line(); } bool is_degenerate() const { return RSegment_2::is_degenerate(); } Bbox_2 bbox() const { return source().bbox() + target().bbox(); } }; #ifndef CGAL_NO_OSTREAM_INSERT_SEGMENT_2 template < class R> std::ostream & operator<<(std::ostream &os, const Segment_2 &s) { typedef typename R::Segment_2_base RSegment_2; return os << static_cast(s); } #endif // CGAL_NO_OSTREAM_INSERT_SEGMENT_2 #ifndef CGAL_NO_ISTREAM_EXTRACT_SEGMENT_2 template < class R> std::istream & operator>>(std::istream &is, Segment_2 &s) { typedef typename R::Segment_2_base RSegment_2; return is >> static_cast(s); } #endif // CGAL_NO_ISTREAM_EXTRACT_SEGMENT_2 CGAL_END_NAMESPACE #endif // CGAL_SEGMENT_2_H