diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Ray_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Ray_2.h index be0daf2a94e..a20dbf15c26 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Ray_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Ray_2.h @@ -65,45 +65,6 @@ public: }; - -#ifndef CGAL_NO_OSTREAM_INSERT_RAYC2 -template < class R > -std::ostream & -operator<<(std::ostream &os, const RayC2 &r) -{ - switch(os.iword(IO::mode)) { - case IO::ASCII : - return os << r.source() << ' ' << r.second_point(); - case IO::BINARY : - return os << r.source() << r.second_point(); - default: - return os << "RayC2(" << r.source() << ", " << r.second_point() << ")"; - } -} -#endif // CGAL_NO_OSTREAM_INSERT_RAYC2 - -#ifndef CGAL_NO_ISTREAM_EXTRACT_RAYC2 -template < class R > -std::istream & -operator>>(std::istream &is, RayC2 &r) -{ - typename R::Point_2 p, q; - - is >> p >> q; - - if (is) - r = RayC2(p, q); - return is; -} -#endif // CGAL_NO_ISTREAM_EXTRACT_RAYC2 - - CGAL_END_NAMESPACE #endif // CGAL_CARTESIAN_RAY_2_H - - - - - - diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/RayH2.h b/Homogeneous_kernel/include/CGAL/Homogeneous/RayH2.h index 8e39d6f4bb6..fc903d00c04 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/RayH2.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/RayH2.h @@ -147,35 +147,6 @@ RayH2 RayH2::opposite() const { return RayH2( start(), - direction() ); } -#ifndef CGAL_NO_OSTREAM_INSERT_RAYH2 -template < class R > -std::ostream & -operator<<(std::ostream &os, const RayH2 &r) -{ - switch(os.iword(IO::mode)) - { - case IO::ASCII : - return os << r.source() << ' ' << r.second_point(); - case IO::BINARY : - return os << r.source() << r.second_point(); - default: - return os << "RayC2(" << r.source() << ", " << r.second_point() << ")"; - } -} -#endif // CGAL_NO_OSTREAM_INSERT_RAYH2 - -#ifndef CGAL_NO_ISTREAM_EXTRACT_RAYH2 -template < class R > -std::istream & -operator>>(std::istream &is, RayH2 &r) -{ - typename R::Point_2 p, q; - is >> p >> q; - r = RayH2(p, q); - return is; -} -#endif // CGAL_NO_ISTREAM_EXTRACT_RAYH2 - template < class R > CGAL_KERNEL_INLINE bool diff --git a/Kernel_23/include/CGAL/Ray_2.h b/Kernel_23/include/CGAL/Ray_2.h index 1f6b54e90b0..1e73915e597 100644 --- a/Kernel_23/include/CGAL/Ray_2.h +++ b/Kernel_23/include/CGAL/Ray_2.h @@ -188,25 +188,73 @@ public: }; -#ifndef CGAL_NO_OSTREAM_INSERT_RAY_2 -template < class R > -std::ostream & -operator<<(std::ostream &os, const Ray_2 &r) + +template +std::ostream& +insert(std::ostream& os, const Ray_2& r, const Cartesian_tag&) { - return os << r.rep(); + switch(os.iword(IO::mode)) { + case IO::ASCII : + return os << r.source() << ' ' << r.second_point(); + case IO::BINARY : + return os << r.source() << r.second_point(); + default: + return os << "RayC2(" << r.source() << ", " << r.second_point() << ")"; + } } -#endif // CGAL_NO_OSTREAM_INSERT_RAY_2 -#ifndef CGAL_NO_ISTREAM_EXTRACT_RAY_2 -template < class R > -std::istream & -operator>>(std::istream &is, Ray_2 &r) +template +std::ostream& +insert(std::ostream& os, const Ray_2& r, const Homogeneous_tag&) { - return is >> r.rep(); + switch(os.iword(IO::mode)) + { + case IO::ASCII : + return os << r.source() << ' ' << r.second_point(); + case IO::BINARY : + return os << r.source() << r.second_point(); + default: + return os << "RayH2(" << r.source() << ", " << r.second_point() << ")"; + } +} + +template < class R > +std::ostream& +operator<<(std::ostream& os, const Ray_2& r) +{ + return insert(os, r, typename R::Kernel_tag() ); } -#endif // CGAL_NO_ISTREAM_EXTRACT_RAY_2 +template +std::istream& +extract(std::istream& is, Ray_2& r, const Cartesian_tag&) +{ + typename R::Point_2 p, q; + is >> p >> q; + if (is) + r = Ray_2(p, q); + return is; +} + + +template +std::istream& +extract(std::istream& is, Ray_2& r, const Homogeneous_tag&) +{ + typename R::Point_2 p, q; + is >> p >> q; + if (is) + r = Ray_2(p, q); + return is; +} + +template < class R > +std::istream& +operator>>(std::istream& is, Ray_2& r) +{ + return extract(is, r, typename R::Kernel_tag() ); +} CGAL_END_NAMESPACE