// ====================================================================== // // 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 : RayH3.h // package : H3 // revision : $Revision$ // revision_date : $Date$ // author(s) : Stefan Schirra // // // coordinator : MPI, Saarbruecken () // ====================================================================== #ifndef CGAL_RAYH3_H #define CGAL_RAYH3_H #include CGAL_BEGIN_NAMESPACE template < class R > class Ray_repH3 : public Ref_counted { public: Ray_repH3() {} Ray_repH3(const PointH3& p, const DirectionH3& d) : startpoint(p), direction(d) {} friend class RayH3; private: PointH3 startpoint; DirectionH3 direction; }; template < class R > class Simple_Ray_repH3 { public: Simple_Ray_repH3() {} Simple_Ray_repH3(const PointH3& p, const DirectionH3& d) : startpoint(p), direction(d) {} friend class RayH3; private: PointH3 startpoint; DirectionH3 direction; }; template < class R_ > class RayH3 : public R_::Ray_handle_3 { public: typedef R_ R; typedef typename R::RT RT; typedef typename R::FT FT; typedef typename R::Ray_handle_3 Ray_handle_3_; typedef typename Ray_handle_3_::element_type Ray_ref_3; RayH3() : Ray_handle_3_(Ray_ref_3()) {} RayH3( const PointH3& sp, const PointH3& secondp) : Ray_handle_3_(Ray_ref_3(sp, (secondp-sp).direction())) {} RayH3( const PointH3& sp, const DirectionH3& d) : Ray_handle_3_(Ray_ref_3(sp, d)) {} const PointH3 & start() const; const PointH3 & source() const; PointH3 second_point() const; PointH3 point(int i) const; const DirectionH3 & direction() const; LineH3 supporting_line() const; RayH3 opposite() const; RayH3 transform( const Aff_transformationH3 & t) const; bool has_on(const PointH3 p) const; bool collinear_has_on(const PointH3 p) const; bool is_degenerate() const; bool operator==(const RayH3& r) const; bool operator!=(const RayH3& r) const; }; template < class R > inline const PointH3 & RayH3::source() const { return Ptr()->startpoint; } template < class R > inline const PointH3 & RayH3::start() const { return Ptr()->startpoint; } template < class R > inline const DirectionH3 & RayH3::direction() const { CGAL_kernel_precondition( !is_degenerate() ); return Ptr()->direction; } template < class R > CGAL_KERNEL_INLINE PointH3 RayH3::second_point() const { return start() + direction().to_vector(); } template < class R > CGAL_KERNEL_INLINE PointH3 RayH3::point(int i) const { CGAL_kernel_precondition( i >= 0 ); return start() + RT(i)*(direction().to_vector() ) ; } template < class R > CGAL_KERNEL_INLINE LineH3 RayH3::supporting_line() const { CGAL_kernel_precondition( !is_degenerate() ); return LineH3(start(), second_point() ); } template < class R > CGAL_KERNEL_INLINE RayH3 RayH3::opposite() const { return RayH3( start(), - direction() ); } template < class R > CGAL_KERNEL_INLINE RayH3 RayH3::transform( const Aff_transformationH3 & t) const { return RayH3(t.transform(start()), t.transform(direction()) ); } #ifndef CGAL_NO_OSTREAM_INSERT_RAYH3 template < class R > std::ostream &operator<<(std::ostream &os, const RayH3 &r) { switch(os.iword(IO::mode)) { case IO::ASCII : return os << r.start() << ' ' << r.direction(); case IO::BINARY : return os<< r.start() << r.direction(); default: return os << "RayH3(" << r.start() << ", " << r.direction() << ")"; } } #endif // CGAL_NO_OSTREAM_INSERT_RAYH3 #ifndef CGAL_NO_ISTREAM_EXTRACT_RAYH3 template < class R > std::istream &operator>>(std::istream &is, RayH3 &r) { PointH3 p; DirectionH3 d; is >> p >> d; r = RayH3(p, d); return is; } #endif // CGAL_NO_ISTREAM_EXTRACT_RAYH3 template < class R > CGAL_KERNEL_INLINE bool RayH3::has_on(const PointH3 p) const { return ( ( p == start() ) ||( DirectionH3(p - start()) == direction() ) ); } template < class R > inline /* XXX */ bool RayH3::collinear_has_on(const PointH3 p) const { return has_on(p); } template < class R > inline bool RayH3::is_degenerate() const { return (Ptr()->direction).is_degenerate() ; } template < class R > CGAL_KERNEL_INLINE bool RayH3::operator==(const RayH3& r) const { return ( (start() == r.start() )&&( direction() == r.direction() ) ); } template < class R > CGAL_KERNEL_INLINE bool RayH3::operator!=( const RayH3& r) const { return !operator==(r); } CGAL_END_NAMESPACE #endif // CGAL_RAYH3_H