diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h index 8ef92f656f0..ba2b80bb690 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h @@ -172,52 +172,6 @@ PointC3::bbox() const return Bbox_3(xp.first, yp.first, zp.first, xp.second, yp.second, zp.second); } -#ifndef CGAL_CARTESIAN_NO_OSTREAM_INSERT_POINTC3 -template < class R > -std::ostream & -operator<<(std::ostream &os, const PointC3 &p) -{ - switch(os.iword(IO::mode)) { - case IO::ASCII : - return os << p.x() << ' ' << p.y() << ' ' << p.z(); - case IO::BINARY : - write(os, p.x()); - write(os, p.y()); - write(os, p.z()); - return os; - default: - os << "PointC3(" << p.x() << ", " << p.y() << ", " << p.z() << ")"; - return os; - } -} -#endif // CGAL_CARTESIAN_NO_OSTREAM_INSERT_POINTC3 - -#ifndef CGAL_CARTESIAN_NO_ISTREAM_EXTRACT_POINTC3 -template < class R > -std::istream & -operator>>(std::istream &is, PointC3 &p) -{ - typename R::FT x, y, z; - switch(is.iword(IO::mode)) { - case IO::ASCII : - is >> x >> y >> z; - break; - case IO::BINARY : - read(is, x); - read(is, y); - read(is, z); - break; - default: - std::cerr << "" << std::endl; - std::cerr << "Stream must be in ascii or binary mode" << std::endl; - break; - } - if (is) - p = PointC3(x, y, z); - return is; -} -#endif // CGAL_CARTESIAN_NO_ISTREAM_EXTRACT_POINTC3 - CGAL_END_NAMESPACE #endif // CGAL_CARTESIAN_POINT_3_H diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/PointH2.h b/Homogeneous_kernel/include/CGAL/Homogeneous/PointH2.h index 45a11217161..3ff8f428a44 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/PointH2.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/PointH2.h @@ -17,7 +17,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Stefan Schirra @@ -53,7 +53,7 @@ public: PointH2() {} - PointH2(const Origin &) + PointH2(const Origin &) : base (RT(0), RT(0), RT(1)) {} PointH2(const RT& hx, const RT& hy ) @@ -81,12 +81,12 @@ public: FT operator[](int i) const; const RT & homogeneous(int i) const; - Cartesian_const_iterator cartesian_begin() const + Cartesian_const_iterator cartesian_begin() const { return Cartesian_const_iterator(static_cast(this), 0); } - Cartesian_const_iterator cartesian_end() const + Cartesian_const_iterator cartesian_end() const { return Cartesian_const_iterator(static_cast(this), 2); } @@ -101,7 +101,7 @@ CGAL_KERNEL_INLINE bool PointH2::operator==( const PointH2& p) const { // FIXME : Predicate - return ( (hx() * p.hw() == p.hx() * hw() ) + return ( (hx() * p.hw() == p.hx() * hw() ) &&(hy() * p.hw() == p.hy() * hw() ) ); } diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/PointH3.h b/Homogeneous_kernel/include/CGAL/Homogeneous/PointH3.h index 173478412e7..5c06ad81603 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/PointH3.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/PointH3.h @@ -17,7 +17,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Stefan Schirra @@ -78,12 +78,12 @@ public: FT operator[](int i) const; - Cartesian_const_iterator cartesian_begin() const + Cartesian_const_iterator cartesian_begin() const { return Cartesian_const_iterator(static_cast(this), 0); } - Cartesian_const_iterator cartesian_end() const + Cartesian_const_iterator cartesian_end() const { return Cartesian_const_iterator(static_cast(this), 3); } @@ -204,53 +204,6 @@ bool PointH3::operator!=( const PointH3 & p) const { return !(*this == p); } -#ifndef CGAL_NO_OSTREAM_INSERT_POINTH3 -template < class R > -std::ostream &operator<<(std::ostream &os, const PointH3 &p) -{ - switch(os.iword(IO::mode)) { - case IO::ASCII : - return os << p.hx() << ' ' << p.hy() << ' ' << p.hz() << ' ' << p.hw(); - case IO::BINARY : - write(os, p.hx()); - write(os, p.hy()); - write(os, p.hz()); - write(os, p.hw()); - return os; - default: - return os << "PointH3(" << p.hx() << ", " - << p.hy() << ", " - << p.hz() << ", " - << p.hw() << ')'; - } -} -#endif // CGAL_NO_OSTREAM_INSERT_POINTH3 - -#ifndef CGAL_NO_ISTREAM_EXTRACT_POINTH3 -template < class R > -std::istream &operator>>(std::istream &is, PointH3 &p) -{ - typename R::RT hx, hy, hz, hw; - switch(is.iword(IO::mode)) { - case IO::ASCII : - is >> hx >> hy >> hz >> hw; - break; - case IO::BINARY : - read(is, hx); - read(is, hy); - read(is, hz); - read(is, hw); - break; - default: - std::cerr << "" << std::endl; - std::cerr << "Stream must be in ascii or binary mode" << std::endl; - break; - } - p = PointH3(hx, hy, hz, hw); - return is; -} -#endif // CGAL_NO_ISTREAM_EXTRACT_POINTH3 - template < class R > inline diff --git a/Kernel_23/include/CGAL/Point_3.h b/Kernel_23/include/CGAL/Point_3.h index 780548ff562..6d6f1b616d6 100644 --- a/Kernel_23/include/CGAL/Point_3.h +++ b/Kernel_23/include/CGAL/Point_3.h @@ -25,6 +25,7 @@ #define CGAL_POINT_3_H #include +#include CGAL_BEGIN_NAMESPACE @@ -166,22 +167,115 @@ bool operator!=(const Origin& o, const Point_3& p) { return p != o; } -#if 0 //ndef CGAL_NO_OSTREAM_INSERT_POINT_3 + +#ifndef CGAL_NO_OSTREAM_INSERT_POINT_3 + +template +std::ostream& +insert(std::ostream& os, const Point_3& p,const Cartesian_tag&) +{ + switch(os.iword(IO::mode)) { + case IO::ASCII : + return os << p.x() << ' ' << p.y() << ' ' << p.z(); + case IO::BINARY : + write(os, p.x()); + write(os, p.y()); + write(os, p.z()); + return os; + default: + return os << "PointC3(" << p.x() << ", " << p.y() + << ", " << p.z() << ')'; + } +} + +template +std::ostream& +insert(std::ostream& os, const Point_3& p,const Homogeneous_tag&) +{ + switch(os.iword(IO::mode)) + { + case IO::ASCII : + return os << p.hx() << ' ' << p.hy() << ' ' << p.hz() << ' ' << p.hw(); + case IO::BINARY : + write(os, p.hx()); + write(os, p.hy()); + write(os, p.hz()); + write(os, p.hw()); + return os; + default: + return os << "PointH3(" << p.hx() << ", " + << p.hy() << ", " + << p.hz() << ", " + << p.hw() << ')'; + } +} + template < class R > std::ostream& operator<<(std::ostream& os, const Point_3& p) { - typedef typename R::Kernel_base::Point_3 Rep; - return os << static_cast(p); + return insert(os, p, typename R::Kernel_tag() ); } + #endif // CGAL_NO_OSTREAM_INSERT_POINT_3 -#if 0 //ndef CGAL_NO_ISTREAM_EXTRACT_POINT_3 -template < class R > -std::istream& operator>>(std::istream& is, Point_3& p) +#ifndef CGAL_NO_ISTREAM_EXTRACT_POINT_3 + +template +std::istream& +extract(std::istream& is, Point_3& p, const Cartesian_tag&) { - typedef typename R::Kernel_base::Point_3 Rep; - return is >> static_cast(p); + typename R::FT x, y, z; + switch(is.iword(IO::mode)) { + case IO::ASCII : + is >> x >> y >> z; + break; + case IO::BINARY : + read(is, x); + read(is, y); + read(is, z); + break; + default: + std::cerr << "" << std::endl; + std::cerr << "Stream must be in ascii or binary mode" << std::endl; + break; + } + if (is) + p = Point_3(x, y, z); + return is; +} + + +template +std::istream& +extract(std::istream& is, Point_3& p, const Homogeneous_tag&) +{ + typename R::RT hx, hy, hz, hw; + switch(is.iword(IO::mode)) + { + case IO::ASCII : + is >> hx >> hy >> hz >> hw; + break; + case IO::BINARY : + read(is, hx); + read(is, hy); + read(is, hz); + read(is, hw); + break; + default: + std::cerr << "" << std::endl; + std::cerr << "Stream must be in ascii or binary mode" << std::endl; + break; + } + p = Point_3(hx, hy, hz, hw); + return is; +} + +template < class R > +std::istream& +operator>>(std::istream& is, Point_3& p) +{ + return extract(is, p, typename R::Kernel_tag() ); } #endif // CGAL_NO_ISTREAM_EXTRACT_POINT_3 diff --git a/Kernel_23/include/CGAL/Sphere_3.h b/Kernel_23/include/CGAL/Sphere_3.h index aaafe9b3a4e..10572f8ba93 100644 --- a/Kernel_23/include/CGAL/Sphere_3.h +++ b/Kernel_23/include/CGAL/Sphere_3.h @@ -153,7 +153,6 @@ public: //return CGAL_NTS is_zero(squared_radius()); } - }; template